所以我想系统打印我的数组列表上的名称之一,我认为它就像我的数组列表上的第二项的 System.out.print(Names[1]) ?
System.out.println("How Many Employees On your Payroll");
Employees = reader.nextDouble();
ArrayList Names = new ArrayList();
for (int i=1;i<=Employees;i++)
{
System.out.println("What is the name for Employee #"+i+"");
String userName = userInputScanner.nextLine();
Names.add(userName);
}
System.out.println("Do these Names Seem Correct?: " + Names);
最佳答案
首先尝试遵守 Java 代码约定: http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-135099.html#367
要获取列表的第二个元素,请使用
names.get(1);
其中 names
是您的列表。
关于java - 如何打印数组列表上的单个项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22023053/