mavidser / SublimeInput

Send STDIN input to programs using comments in Sublime Text 2/3
37 stars 2 forks source link

Am I missing something? Testing it in Java #13

Closed octohedron closed 8 years ago

octohedron commented 8 years ago
class text {
    public static void main(String []args) {
        try{
                Scanner sc = new Scanner(System.in);
                /*input
                Hello
                */
                String s = sc.nextLine();
                System.out.println(s);
            } catch( Exception ex){
                    System.out.println(ex);
            }
    }
}

prints an empty line, am I missing something?

mavidser commented 8 years ago

Hi. The way it works is you put the input on the top of the file. So,

/*input
Hello
*/
class text {
    public static void main(String []args) {
        try{
                Scanner sc = new Scanner(System.in);
                String s = sc.nextLine();
                System.out.println(s);
            } catch( Exception ex){
                    System.out.println(ex);
            }
    }
}