我尝试编写一个程序来查找最大数,但结果显示为“0”。这是我的代码:
public class Max_N_value {
public Max_N_value() {}
public static void main(String[] args) {
int i; int mynum[] = new int[50];
for( i=0;i<5;i++)
mynum[i]=Integer.parseInt(JOptionPane.showInputDialog(null," Value "));
if(mynum[i]>mynum[i+1]) {
JOptionPane.showMessageDialog(null,"Maximum value is "+mynum[i]);
else {
JOptionPane.showMessageDialog(null,"Maximum value is : "+mynum[i+1]);
}
}
}