Jump to content
  • Advertisement
Sign in to follow this  
jolyqr

[java] java.lang.NullPointerException

This topic is 4449 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

basically I've got a java project which contains 2 classe: public class user { String user; String real_name; String character_name; int character_age; } and public class principal{ void myFunction() { user[] TheUser; [......] TheUser=new user[10]; TheUser[0].user=user; TheUser[0].character_name=character_name; TheUser[0].real_name=real_name; TheUser[0].character_age=Integer.valueOf(character_age); } } when i try to execute the above lines, i've got an java.lang.NullPointerException, the problems come from TheUser.... if someone has a clue, let me know. cheers !!

Share this post


Link to post
Share on other sites
Advertisement
All you did with the array is to create a new array of user objects. You didn't create any new user objects. You need a for loop.

for( i = 0; i < TheUser.length; i++ ) {
TheUser[ i ] = new user();
}

Share this post


Link to post
Share on other sites
Quote:
Original post by GKW
All you did with the array is to create a new array of user objects. You didn't create any new user objects. You need a for loop.
*** Source Snippet Removed ***


Oh really!!!, thanks for the tips !!!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!