public int checkC(String s){ char []a = {'1','2','3','4','5','6','7','8','9','0','-','+','*','/','(',')'};
char []c = {‘5’,‘-’,‘2’}
int i=0;
int j=0;
for(i=0;i<c.length-1;i++)
{
for(j=0;j<a.length-1;j++)
{
if(c[j]==a[i]){
int t = calcu(s);
System.out.print(t);
}else{
JOptionPane.showMessageDialog(null,"输入了错误的字符");
}
}
}
return 0;
}
char []c = {‘5’,‘-’,‘2’}
int i=0;
int j=0;
for(i=0;i<c.length-1;i++)
{
for(j=0;j<a.length-1;j++)
{
if(c[j]==a[i]){
int t = calcu(s);
System.out.print(t);
}else{
JOptionPane.showMessageDialog(null,"输入了错误的字符");
}
}
}
return 0;
}
能明白吧!
能明白吧!=======================================
胡说,char是基本类型的就用==来比较,楼主的数组越界错误
改为c[i]==a[j]就对了