我想用
Java打印一个List.
r1
r2
r3
r4
这是代码:
public static final void main(String args[]) {
Scanner a = new Scanner(System.in);
String r1, r2, r3, r4;
System.out.print("Enter word..");
r1 = a.next();
System.out.print("Enter second word");
r2 = a.next();
System.out.print("Enter third word");
r3 = a.next();
System.out.print("Enter last word");
r4 = a.next();
List list = new List();
list.add(r1);
list.add(r2);
list.add(r3);
list.add(r4);
System.out.println(list);
}
如何让它打印我的列表而不是:
java.awt.List[list0,0,0,0x0,invalid,selected=null]