-1

这是我的代码,我仍然不知道我的问题是什么

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");
4

3 回答 3

2

你错过了关闭}你的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");

使用适当的缩进,这将帮助您找到这些错误。

于 2013-11-13T15:23:34.057 回答
2

你错过了一个}。

应该

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");
于 2013-11-13T15:25:54.790 回答
1
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");
于 2013-11-13T15:24:29.003 回答