我明天有这个任务,我是初学者,请帮忙。必须是 JOptionpane :OI 想知道我是否可以在 showmessagedialog 中使用 if else 语句。错误说需要不兼容的类型: int ( for holder=holder + "\n" + aw[x]; 这是我到目前为止所做的(对不起,我是初学者,请理解):
public static void main(String[] args) {
String s;
int size;
int size2;
int holder;
s = JOptionPane.showInputDialog("Enter the size of the array");
size = Integer.parseInt(s);
String aw[]= new String[size];
for (int x=0; x<=aw.length-1; x++){
aw[x]=JOptionPane.showInputDialog("Enter value for array[" + x + "]");
size2 = Integer.parseInt(aw[x]);
}
for (int x=0; x<=aw.length-1;x++)
{
holder=holder + "\n" + aw[x];
}
JOptionPane.showMessageDialog(null, if (holder<0) { holder + " is negative" } else holder " is positive");
}
}'