Linked Questions

Popular Questions

Java user console input on sublime text 3 not working

Asked by At

I am trying to get the user to enter their name and have it be printed out on java using Sublime Text 3. After the user enters their name when a message prompts them for it, their name is supposed to be printed out but it justs skips over to a new blank line. It works on online compilers but not on Sublime. How do I get user console input to work on Java Sublime Text 3?

import java.util.Scanner;

public class SocSecProcessor {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        System.out.print("Enter name: ");
        String name = input.nextLine();
        input.close();
        System.out.println(name);

    }

}

Related Questions