0
I migrated from C to Java and would like to know which command allows the user to enter external data and what would this command look like in code.
In language in C
use the code below:
scanf(%tipo_da_variavel, &nome_da_variavel);
0
I migrated from C to Java and would like to know which command allows the user to enter external data and what would this command look like in code.
In language in C
use the code below:
scanf(%tipo_da_variavel, &nome_da_variavel);
1
The scanf()
in C is equivalent to Scanner
in Java. See below for an example:
Scanner scanner = new Scanner(System.in);
// valores do tipo inteiros
int n = scanner.nextInt();
// valores do tipo strings
String s = scanner.nextLine();
// valores do tipo double
double d = scanner.nextDouble();
See more details and examples in the documentation on the scanner class.
Browser other questions tagged java c
You are not signed in. Login or sign up in order to post.
Which command you use in C?
– viana
In C it would be scanf(%type_da_variable, &variable_name);
– João Dias
In java is
Scanner ler = new Scanner(System.in); int n = ler.nextInt();
– viana
@acklay wants to answer?
– Maniero
@acklay reopened.
– Maniero