I think what you want is an Object, just create a class yourself. For example:
public class Person
{
private String name;
private int age;
private Color favoriteColor;
public Person(){
// perhaps add some defaults here
}
public void setName(String n){
name = n;
}
public String getName(){
return name;
}
public void setAge(int a){
age = a;
}
public int getAge(){
return age;
}
public void setFavoriteColor(Color c){
favoriteColor = c;
}
public Color getFavoriteColor(){
return favoriteColor;
}
}
In your main app you can then create this Object like so:
Person person = new Person();
Store the user inputs in it. So when the user adds a name:
person.setName(nameThatWasInputtedByTheUser);
You can store all of these UserInputContainers in a list:
ArrayList<Person> list = new ArrayList<Person>(); // or "new ArrayList<>();" when you use Java 8.0+
Then at the end you can get all this again like so:
System.out.println("Person at index " + index);
Person currentPerson = list.get(index);
System.out.println("Name: " + currentPerson.getName());
System.out.println("Age: " + currentPerson.getAge());
System.out.println("Color: " + currentPerson.getColor());
ArrayList<Person> peoplewherePersonhas methodsgetName(),getAge(),getFavouriteColour()? Thenpeople.get(i).getName()would be Luke, etc.