2015-08-18 45 views
-6

当我的应用程序编译,它不会接受在它问:“请输入一个房间搜索:”同线roomNum输入为什么扫描仪不能接受println上的输入?

System.out.println(); 
if(roomNum < 0); 
{ 
    System.out.println("Please enter a room to search for: "); 
    roomNum = input.nextInt(); 
} 

如果我只是用next代替nextInt,它不能正确编译。

上面的代码工作,但不会接受同一行上的输入,这是我需要的功能。

+9

删除'if'行上的分号。 – rgettman

回答

2

两件事:在if条件后删除分号,如果要在同一行输入,则使用System.out.print()

+0

谢谢@akaHuman。那样做了。我是新人!今天学到了一些新东西。 –