****它在JOptionPane代码中抛出NullPointerException,如下所示。****
public static void main(String[]args){
String[] options={"Do it again?", "Exit"};
int response=0;
int indexOfZip;
do{
try{
String dataStr=JOptionPane.showInputDialog("Enter a zip code");
if(dataStr!=null){
while (k<i){
if (place[k].equals(dataStr)){
indexOfZip=k;
k++;
}
}
int data=Integer.parseInt(dataStr);
response=JOptionPane.showOptionDialog(null,
"You asked me to search for zip code:"+dataStr+"The zip code "+dataStr+" belongs to"+place[k].getTown()+","+place[k].getState()+"Do you want me to search again?",
"results",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
options,options[0]);
System.out.println("You asked me to search for zip code:"+dataStr);
System.out.println("The zip code "+dataStr+" belongs to"+place[k].getTown()+","+place[k].getState());
System.out.println("Do you want me to search again?");
}
}catch(NumberFormatException e){
JOptionPane.showMessageDialog(null,"Bad Numeric String, try again.", "Input Error",JOptionPane.ERROR_MESSAGE);
}
}while(response==0);
if (response!=0){
System.out.print("No");
System.out.println("Good Bye!");
}
}
终端表示此行的例外情况 响应= JOptionPane.showOptionDialog(NULL,
但我在这里看不出任何错误,因为“响应”在之前被初始化了。
答案 0 :(得分:0)
看起来window.onload = ->
$('.box').find('img').each ->
imgClass = if @width / @height > 1 then 'wide' else 'tall'
$(this).addClass imgClass
return
return
必须是place[k]
,
和null
触发place[k].getTown()
。
在调试器中观察NullPointerException
的值(或添加打印语句)。