I have two classes, Teacher and Pupil. In the Teacher class there is an array list of Pupil's (containing instances of Pupil).
I'd like to do something like:
System.out.println(pupils.get(1).getName())
where getName is a method from the Pupil class. However, pupils.get(1) does not seem to act as a Pupil and won't let me call this method. How should I do it?