I have two arrays of objects and I am trying to combine the two in one class.
final Object[] newarray = ArrayUtils.addAll(part1, part2);
part1 is in a different class than part2. I know the code above is wrong, please don't correct me on that. That is just how I am going to add the two. I have tried setting up setter and getter methods with no luck. Am I going about this the wrong way?
EDIT:
Class 1 {
Object[] part1 = new Object[]{
new Object(),
new Object(),
new Object(),
new Object(),
new Object(),
}
Class 2 {
Object[] part2 = new Object[]{
new Object(),
new Object(),
new Object(),
new Object(),
new Object(),
}
@Override
protected void onCreate(Bundle savedInstanceState) {
final Object[] newarray = ArrayUtils.addAll(part1, part2);
ArrayAdapter<Object> myAdapter = new ArrayAdapter<Object>(this, R.layout.row, newarray);
busroutelist.setAdapter(myAdapter);
}
}
Assuming you don't have instances of those classes, you would need to do the following:
final Object[] newarray = ArrayUtils.addAll(new Class1().part1, new Class2().part2);
That way you are creating an instance of each class, and once the instances exist, you can access the properties they hold. I recommend you review some object oriented programming theory to better understand the what a classes, instances and objects are and how they work.