So in the program u helped me with, u wanted me to create a list of 20 names using loops? I can use array and then use a loop to store 20 names, but how to i create multiple object using a loop, like S1, S2 and so on? Dorje
zeePa · May 10, 2009 8:45 AM · 2,907 views
Student s[] = new Student[20]; LinkedList l = new LinkedList(); for(int i=0;i<20;i++) { //fname = get firsname from user //lname = get lastname from user //for eg. i'm hard coding the values //This will store AAA and BBB for all 20 objects //if you take it from user it will be diff. s[i]= new Student("AAA","BBB"); l.add(s[i]); }
techGuy · May 10, 2009 12:42 PM
This conversation is preserved exactly as it was on the original Sajha.com and can't accept new replies.
Start a New Discussion