Hi, I'm trying to create an Arraylist Class which will allow me to output the whole list in one method. I think i've created the arraylist correctly but when i try to get the list to output i come across problems.
Here is my code,
I've also tried to put the last two statements in a seperate method but the compiler can't find the variable people when i do this.
Any help would be much appreciated!
Thanks
Dave
Here is my code,
Code:
import java.util.*; import java.util.ArrayList.*; public class People { public static void main (String[] args) { Person Chris = new Person("Chris", "Davies", 10, 7); Person Jess = new Person ("Jess", "Levy", 4, 17); Person Koo = new Person ("Tom", "McHowat", 4, 14); Person Andy = new Person ("Andy", "Davies", 3, 6); ArrayList<Person> people = new ArrayList<Person>(); people.add(Chris); people.add(Jess ); people.add(Koo ); people.add( Andy ); int i = people.size(); Person allPeople = people.get(i-1); } }
Any help would be much appreciated!
Thanks
Dave
Comment