[Java] Baekjun number 10926 - ??!
We have summarized how to receive string input in Java and output characters that match the conditions.
한국어 원문은 여기에서 볼 수 있습니다.
[Java] Baekjun number 10926 - ??!
Solution
1
2
3
4
5
6
7
8
9
10
11
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
String name = input.next();
System.out.printf(name + "??!");
}
}
Strings in Java
- Receive string input using
Stringclass
Difference between next() and nextLine()
- When inputting a string in Java, input can be received through
.next()and.nextLine()from theStringclass..next(): Receives input of characters or strings one by one, one word or one character at a time.- ex) If you enter
Hello World!, onlyHellowill be entered..nextLine(): Receives input of characters or the entire sentence before hitting enter. - ex) If you enter
Hello World!, the entireHello World!will be entered.
- ex) If you enter