【发布时间】:2014-08-13 13:17:43
【问题描述】:
System.out.print("Enter Number to Search: ");
String get = br.readLine();
int input = Integer.parseInt(get);
for(int i = 0; i < 5; i++)
{
num[i] = inFile.nextInt();
}
for(int j = 0; j < 5; j++)
{
if(input == num[j])
{
System.out.println("Search number is found!");
break;
}
else
{
System.out.println("Search number is lost!");
}
}
num[i] 中的数字是 1, 2, 3, 4, 5。
我的问题是,当我尝试搜索数字 5 时,输出是这样的:
Enter Number to Search: 5
Search number is lost!
Search number is lost!
Search number is lost!
Search number is lost!
Search number found!
如何打印“找到的搜索号码!”不打印“搜索号丢失!”??
【问题讨论】:
-
删除
println?
标签: java for-loop conditional-statements