How to create a list/structure? in JAVA
Posted
by lox
on Stack Overflow
See other posts from Stack Overflow
or by lox
Published on 2010-05-04T15:03:40Z
Indexed on
2010/05/04
15:08 UTC
Read the original article
Hit count: 268
i have to create a list of ,let's say 50 people, (in JAVA) and display the list, and i don't really know how to do that. so this is what i have tried to do so far . please correct and complete some of my code .
public class Person {
String name;
String stuff;
}
public class CreatePerson {
public static void ang() {
ArrayList<Person> thing=new ArrayList<Person>();
Scanner diskScanner = new Scanner(in);
for(int i=0; i<50; i++){
Person pers = new Person();
out.print("name: ");
pers.name=diskScanner.nextLine();
out.print("stuff: ");
pers.stuff=diskScanner.nextLine();
thing.add(pers);
break;
}
// Display people
for (int i=0; i<50; i++) {
out.println(??);{
}
} }}
© Stack Overflow or respective owner