The easiest way to get user input is by Scanner class where you can get user input from String( Text) to integer like numbers, so if this is your goal then please follow these easy steps to make this happen, just a head up that i’m using Eclipse but feel free to use any Editor you want.

    1- Open your Favorite editor i’m using Eclipse
    2- go to New > Java Project > give your project a name and then Accept the default settings.
    3- once you create your project then you have to create a main method there is very handy way to do this in Eclipse I have explained this in my video the short cut in Mac is first you have to type main then Control+space.
public class userinput {

	public static void main(String[] args) {

so in above code I named my class userinput and then following to that I created my main method, what main method does is once you run your program the firs class that would be executed would be this main method everything goes into this.

java; highlight: [1,5]; title: ; notranslate" title="">
import java.util.Scanner;
public class userinput {

	public static void main(String[] args) {
		
		Scanner values = new Scanner(System.in);

so in above code I have created a scanner object at line 5 and then at line one you can see I have imported the scanner class without which you will get error as in java whatever class you are using you have to import it at the top of your class the example you can see at line 1 of above code


import java.util.Scanner;

public class userinput {

	public static void main(String[] args) {
		
		Scanner values = new Scanner(System.in);
		
		System.out.println("Please enter your name: ");
		
		String urname = values.nextLine();
		
		System.out.println("Your name is " + urname);
		
		
	}
}

so finally you can see in above code I have used system out put to give user a friendly message to enter his/her input to the scanner object and once they done after pressing Enter the scanner object pass the data to variable we created in 13, and after that it will System out the variable with the text we specify.

Open the youtube here

hope this help you to get user input in java if so please share with your friend and subscribe to my youtube channel I would like to get your feedback on what you want to learn so I adjust my videos and blogs according to that soon I will be going to start the java from Start to finish to show you how to make simple command line application, so your feedback will always welcome.

till then happy coding XD