+ 1

Java user input is just by scanner?

I'm learning java now and I'm a bit confused about the user input, in c i'd use scanf, but with java the best option I found was the scanner, is there other options? https://code.sololearn.com/cmsl91jVHuNN/?ref=app

7th May 2018, 3:48 AM
Joao Luiz de Castro
Joao Luiz de Castro - avatar
6 Respuestas
+ 9
/*or this*/ import java.util.*; public class Program { public static void main(String[] args) { int n = new Scanner(System.in).nextInt(); System.out.printf("Digite Aqui um Numero: %d",n); } }
7th May 2018, 7:20 AM
D_Stark
D_Stark - avatar
+ 8
/*you could do this */ import java.util.*; public class Program { public static void main(String[] args) { System.out.println("Digite Aqui um Numero: "+new Scanner(System.in).nextInt()); } }
7th May 2018, 7:17 AM
D_Stark
D_Stark - avatar
+ 6
Joao Luiz de Castro JOptionPane class is used to provide standard dialog boxes such as message dialog box, confirm dialog box and input dialog box. These dialog boxes are used to display information or get input from the user. See how to implement it and more related to it. https://www.javatpoint.com/java-joptionpane
7th May 2018, 4:10 AM
Akash Pal
Akash Pal - avatar
+ 2
Akash Pal Donna D_Stark thank you guys! I'll try these solutions and I'll come back if things get complicated. you guys great!
7th May 2018, 11:38 AM
Joao Luiz de Castro
Joao Luiz de Castro - avatar