这是我的代码,我仍然不知道我的问题是什么
if ((int) ch[j]== (int) ch2)
{ for ( k=j; k<=j ; k++){
System.out.print(ch[j]+" ");
}
else
System.out.print("Sorry we didn't find it");
这是我的代码,我仍然不知道我的问题是什么
if ((int) ch[j]== (int) ch2)
{ for ( k=j; k<=j ; k++){
System.out.print(ch[j]+" ");
}
else
System.out.print("Sorry we didn't find it");
你错过了关闭}
你的if
if ((int) ch[j]== (int) ch2){
for ( k=j; k<=j ; k++){
System.out.print(ch[j]+" ");
} //for loop closing
} //here (missing for if)
else
System.out.print("Sorry we didn't find it");
使用适当的缩进,这将帮助您找到这些错误。
你错过了一个}。
应该
if ((int) ch[j]== (int) ch2)
{ for ( k=j; k<=j ; k++){
System.out.print(ch[j]+" ");
}
}
else
System.out.print("Sorry we didn't find it");
if ( (int) ch[j] == (int) ch2)
{
for ( k=j; k<=j ; k++)
{
System.out.print(ch[j]+" ");
}
**}**
else
System.out.print("Sorry we didn't find it");