不太清楚为什么这不起作用,当我尝试编译和运行时,它给了我一个空指针异常。我知道这非常简单,可能是一个愚蠢的问题,但我似乎无法弄清楚!
import javax.swing.JOptionPane;
public class Whatever
{
private int age;
private String name;
private float salary;
public Whatever ()
{
String userName = JOptionPane.showInputDialog ("What is your name?");
Whatever listData[] = new Whatever [10];
listData[6].name = userName;
}
public static void main (String [] args)
{
Whatever testWhatever = new Whatever ();
}
}