Java program | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Java program

How can i make an input place if i wanted to make it able to assign for variables.4 ex:name = "input here"; My quiestion is just...how can i do that?

2nd Nov 2020, 10:50 AM
Faceless
Faceless - avatar
4 Answers
+ 1
Depends on the type of input you would like take from the user. Scanner sc = new Scanner(System.in); // For String String a = sc.nextLine(); // For integer int b = sc.nextInt(); // For double double c = sc.nextDouble(); And so on.
2nd Nov 2020, 11:02 AM
Avinesh
Avinesh - avatar
+ 3
What do you mean by input place? do you mean.... String str=new Scanner(System.in).nextLine();
2nd Nov 2020, 10:54 AM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar
+ 2
Isn't it basically taking user input? This is discussed in the course. You must make use of Scanner class. https://www.sololearn.com/learn/Java/2220/
2nd Nov 2020, 10:57 AM
Avinesh
Avinesh - avatar
0
Yes exactly, but what code should i use specificly?
2nd Nov 2020, 10:59 AM
Faceless
Faceless - avatar