This is the class that creates the objects:
class cards_type{
String color;
String number;
public cards_type(final String input_color, final String input_number) {
color = input_color;
number = input_number;
}
}
And this are the arraylist:
ArrayList<ArrayList>players_cards = new ArrayList<ArrayList>();
players_cards.add(new ArrayList<cards_type>());
When I add the values and print it with this code, it returns the object:
System.out.println(players_cards.get(0).get(0));
OUT: cards_type@ea4a92b
But if I instance a property it returns a mistake like if it wasnt a object:
System.out.println(players_cards.get(0).get(0).color);
OUT: Exception in thread "main" java.lang.Error: Unresolved compilation problem: color cannot be resolved or is not a field
Thanks for help
System.out.println(players_cards.get(0).get(0));You just added the arrayList of cards_type ,but you did not initialize it. So second get(0) will give you null pointer exception