0 votes
in JAVA by
how to read string in java?

1 Answer

0 votes
by
"import java.util.Scanner;  // Import the Scanner class

class MyClass {

  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

  }

}"

Related questions

0 votes
asked Oct 10, 2020 in JAVA by Robindeniel
0 votes
asked Oct 11, 2020 in JAVA by SakshiSharma
...