当我运行这段代码时,我只会得到一长串这样的名字:
Jones, Jon BS, Wells, Lisa HS, Ryes, Ric DR
但我想要的是单独打印每一个
Jones, Jon BS
Wells, Lisa HS
Ryes, Ric DR
我正在为这个程序使用两个类,我的主要是
import javax.swing.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
public class someName
{
public static void main (String[] args)
{
....//set all my variables and prompted user for number of Inputs
{
fName = JOptionPane.showInputDialog(null,"Enter "+i+" First Name: ");
lName = JOptionPane.showInputDialog(null,"Enter "+i+" Last Name: ");
level = JOptionPane.showInputDialog(null,"Enter "+i+" Highest Level of Degree: ");
someClass t = new someClass(fName,lName,level);
listOfName[i] = t;
}
for(int i = 0; i<numPerson; i++)
{
System.out.println(Arrays.toString(listOfName));
}
}
}
当我改变
System.out.println(Arrays.toString(listOfName));
到
System.out.println(Arrays.toString(listOfName[i]));
我收到一个错误说明
java:29: error: no suitable method found for toString(someClass)
非常感谢任何和所有帮助。