Q) BAEKJOON / JAVA / 2557 : Hello World
https://www.acmicpc.net/problem/2557
A)
- [1] System 클래스 : 표준 입출력
public class Main {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
- [2] IO 클래스 : 버퍼 입출력
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
bw.write("Hello World!");
bw.flush();
bw.close();
}
}
- [3] StringBuilder : 문자열 조작시 유용
public class Main {
public static void main(String[] args){
StringBuilder sb = new StringBuilder();
sb.append("Hello World!");
System.out.println(sb);
}
}
- [4] StringBuffer : 동기화 지원
public class Main {
public static void main(String[] args){
StringBuffer sb = new StringBuffer();
sb.append("Hello World!");
System.out.println(sb);
}
}