如何在一条 JOptionPane 消息中显示带有相应数组的零、正、负字符串?
这是代码....
String display="";
int z = 0;
String size = JOptionPane.showInputDialog("Enter Your Prefered Size Of Your Array");
int newsize = Integer.parseInt(size);
JOptionPane.showMessageDialog(null,"You Entered "+newsize+".");
int array[] = new int [newsize];
for (int a=0; a<array.length;a++)
{
array[a] = Integer.parseInt(JOptionPane.showInputDialog("Enter Value For Array["+a+"]."));
}
for (int a=0;a<array.length;a++)
{
display=display+array[a]+"\n";
if (z == array[a])
{
String c=array[a]+" ZERO";
JOptionPane.showMessageDialog(null,"Arrays\n"+display+c);
}
else if (z < array[a])
{
String c =array[a]+" POSITIVE";
JOptionPane.showMessageDialog(null,"Arrays\n"+display+c);
}
else if (z != array[a])
{
String c =array[a]+" NEGATIVE";
JOptionPane.showMessageDialog(null,"Arrays\n"+display+c);
}
JOptionPane.showMessageDialog(null,"Arrays\n"+display+c);
}