I've created an ArrayList called groupOfPeople by having a constructor that takes their name and ages. This was added to the ArrayList like this:
groupOfPeople.add(new Person(23,"Tom"));
Now I want to make that person call a sleep() method that is stored within another class. I've called it like this:
SleepClass callSleepClassr = new SleepClass();
Now I want to call the first person in the ArrayList and make them sleep so adding .callSleepClass.sleep() to them. The thing is, I don't know how to refer to that first array.
Any help is appreciated, thank you.
for (Person x : people) { x.callshower.shower(); }doesn't work, how would I make x do this?