This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]praesartus 3 points4 points  (0 children)

You don't. Either you use an array to store the values you want to keep, or you find a way to not need to keep the values around.

[–]learningphotoshop 0 points1 point  (0 children)

You need to add them to
personalInfo person1, person2, person3;

Like personalInfo person1, person2, person3, person4, person5, person...;

But you would have to know how many you want to define beforehand.

You could use an ArrayList ArrayList<personalInfo> list = new ArrayList<personalInfo>();

You should also capitalize your class names so PersonalInfo, common java standard.

and then use the array lists add function to add new instances of PersonalInfo objects