下面是我的问题
1. In an ArrayList we used below function to ask user to input 20 data, so, how to rewrite this ?
2. Function using the LinkedList method?
3. Is it possible to ask user to input the data and stored it in a LinkedList way...?
代码:
public static void main(String[] args)
{
ArrayList al = new ArrayList(20);
Scanner in = new Scanner(System.in);
Student st;
String name, id;
float cgpa;
for(int i=0; i<20; i++)
{
System.out.println("Name : ");
name = in.next();
System.out.println("ID : ");
id = in.next();
System.out.println("CGPA : ");
cgpa = in.nextFloat();
st = new Student(name, id, cgpa);
al.add(i,st);
}