Answers for "java how to read in userinput"

0

java how to read in userinput

import java.util.Scanner;  // Import the Scanner class

class Main {
  public static void main(String[] args) {
    Scanner myObj = new Scanner(System.in);  // Create a Scanner object
    System.out.println("Enter username");

    String userName = myObj.nextLine();  // Read user input
    System.out.println("Username is: " + userName);  // Output user input
  }
}
Posted by: Guest on September-16-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language