dai*_*dai 10 java intellij-idea
我需要打开控制台并使用Intellij输入我的作业输入.Eclipse有一种方法可以使用Scanner类和读取来执行此操作,System.in但在IntelliJ中运行相同的代码不起作用,因为我无法在控制台中键入任何内容.
有没有办法做到这一点?
我的代码如下:
public class BasicAssertions {
@Test
public void testAssertions(){
System.out.println("Enter: ");
Scanner reader = new Scanner(System.in);
int first = reader.nextInt();
int second = reader.nextInt();
String s = reader.next();
String s2 = reader.next();
assertTrue(first<=second);
assertFalse(first+second >100);
assertNotEquals(s,s2);
assertNotNull(s2);
}
}
Run Code Online (Sandbox Code Playgroud)
只需单击控制台窗口并键入,它就适用于IntelliJ 13 CE.看到下面的图片,我点击了控制台并写了文字(它显示为绿色然后,我输入并显示):

| 归档时间: |
|
| 查看次数: |
11626 次 |
| 最近记录: |