Check out example codes for "how to get a user input in java". It will help you in understanding the concepts better.

Code Example 1

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

class MyClass {
  public static void main(String[] args) {
    Scanner myObj = new Scanner(;  // 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

Code Example 2

InputUSer Scanner

Learn ReactJs, React Native from