java - 在线编译器与本地编译器

标签 java online-compilation

import java.util.Scanner;
public class Count {
       public static void main(String []args){
       Scanner s=new Scanner(System.in);
       int i=s.nextInt();
       int j=i+1;
       System.out.println(j);
    }

}

这是java中的基本代码,当我在自己的PC上运行它时它运行良好,我在Online compiler上编译和执行的代码相同,它给出了一些错误,为什么??

Exception in thread "main" java.util.NoSuchElementException
    at java.util.Scanner.throwFor(Scanner.java:907)
    at java.util.Scanner.next(Scanner.java:1530)
    at java.util.Scanner.nextInt(Scanner.java:2160)
    at java.util.Scanner.nextInt(Scanner.java:2119)
    at Count.main(Count.java:28) 

最佳答案

有一个field用于向 STDIN 提供输入参数。

During your program you may ask user to input some values in the form of number or strings. Because on the web we can not give interactive option to provide input, so we provided this option to provide all the inputs in one line which will be read by your program using different functions available in your programming language.

enter image description here

关于java - 在线编译器与本地编译器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22011843/

相关文章:

java - ajax 发布后需要在下一个选项卡上显示数据库中的数据

c++ - 在 Hackerearth 上出现运行时错误(SIGSEGV),无法找出代码中的问题

java - 如何制作Web App在线编译运行Java/C/PHP代码?

java - 构建和部署成功,但没有 Web 进程在 Spark 上的 Heroku 上运行(Java 框架)

java - 如何将文件复制到特定路径?

java - 从重定向 URL header 获取位置

javascript - 将输入数据发送到 node.js 中的子进程

java - 这里的 != 运算符有什么问题?

ide - Codepad/ideone 风格的协作 Web IDE?

java - 是否可以在数据库中安装 Java 编译器?