Java Stdin and Stdout lI | HackerRank | Solution | 4
Автор: Get Answer with Jeeva
Загружено: 2024-08-08
Просмотров: 9
Описание:
Java Stdin and Stdout lI | HackerRank | Solution | 4
1. `Scanner scan = new Scanner(System.in);`
Creates a new `Scanner` object to read input from `System.in` (the console).
2. `int i = scan.nextInt();`
Reads an integer from the console and assigns it to `i`.
3. `double d = scan.nextDouble();`
Reads a double-precision floating-point number from the console and assigns it to `d`.
4. `scan.nextLine();`
Consumes the newline character left in the input buffer after reading the double.
5. `String s = scan.nextLine();`
Reads a line of text from the console and assigns it to `s`.
6. `System.out.println("String: " + s);`
Prints the string `s` to the console, preceded by "String: ".
7. `System.out.println("Double: " + d);`
Prints the double `d` to the console, preceded by "Double: ".
8. `System.out.println("Int: " + i);`
Prints the integer `i` to the console, preceded by "Int: ".
#code #getanswerwithjeeva #java #questionanswer #hackerranksolution #questions
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: