缺少返回语句

sunny_one 2008-05-11 02:02:21
public static boolean Test (String temp) throws IOException
{
int flag=0;
for(int i=0;i<temp.length();i++)
{
if ((temp.substring(i,1)=="0"||(temp.substring(i,1)=="1")))
flag+=1;
else
{
System.out.println("You must enter 0 or1!!\n");
temp = bufferedreader.readLine();

break;

}

}

if (flag==temp.length())
return true;

else
Test(temp);

}


编译时老是提示最后一行有缺少返回语句错误.哪位大哥能给个指点?谢谢!!
...全文
110 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunny_one 2008-05-11
  • 打赏
  • 举报
回复
谢谢~~~
Fenglee2008 2008-05-11
  • 打赏
  • 举报
回复
ls正解!
anqini 2008-05-11
  • 打赏
  • 举报
回复
if (flag==temp.length())
return true;

else
Test(temp);
return false或者true;

万一上面的if不执行就没有return 了

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧