public class One{
public List<Loots> lootsList = new ArrayList<Loots>();
public void someVoid(){
new Two(this);
}
}
public class Two
{
One one;
public Two(One one){
this.one = one:
}
Loots MyLoots = new Loots();
// How to add in THIS class, MyLoots to lootsList?
public void someVoid(){
one.lootsList.add(MyLoots);
}
}
This is a better way to do it because the ArrayList can hold as many objects as you need without it being defined by the initialization of the list.
BY defining it like you did, there has to be a specific amount of Loots max in the array.
Alternative:
public static Loots[] lootsList = new Loots[20];
Example:
public class One{
public static Loots[] lootsList = new Loots[20];
public void someVoid(){
new Two(this);
}
}
public class Two
{
One one;
public Two(One one){
this.one = one:
}
Loots MyLoots = new Loots();
// How to add in THIS class, MyLoots to lootsList?
public void someVoid(){
one.lootsList[0].add(MyLoots);
}
}
ListorArrayListinstead. Much easier.