I am thinking of creating a complex data type myself, but just not sure of the cost of it.
Let's say , I have 3 lists, name,age,gender,
List<String> name = new ArrayList<String>;
List<Integer> age = new ArrayList<Integer>;
List<String> gender = new ArrayList<String>;
I would like to combine each element of these lists together, something like this:
public class Person {
private String name;
private int age;
private String gender;
public void Person(String name,int age,String gender){
this.name = name;
this.age = age;
this.gender = gender;
}
public void getName () {
return name;
}
public void getAge () {
return age;
}
public void getGender () {
return gender;
}
}
then I can create the object that contains these information:
Person person1 = new Person("John",22,"Male")
;
But the thing is the list of name is so big that may have 1,000,000 names(also the list of age and gender),meaning I would need to create 1,000,000 objects of Person. Is this a good idea to pass object containing name,age and gender to another class or I should just pass these name,age,gender separately?
How big would a object containing name,age and gender be, compared to the cost of String name, int age and String gender added together?