1, 출력
System.out.print();
public class Main {
public static void main (String args[]) {
System.out.print("World");
}
}
결과: world
2. 문장 출력
public class Main {
public static void main (String args[]) {
System.out.print("Hello World!");
}
}
결과:Hello World!
3. 문자열에 특수 문자 포함 시키기
\"하면 "을 포함된 상태로 출력 가능
public class Main {
public static void main (String args[]) {
System.out.print("\"Hello\"");
}
}
결과:"Hello"
4. 2줄 출력
줄 바꿈 출력
1) System.out.println("출력할 값")
2) \n 사용
public class Main {
public static void main(String[] args) {
// Your Program Goes Here
System.out.println("Hello");
System.out.println("World");
}
}
결과: Hello
World
5. 숫자 출력
1) System.out.print()
2) System.out.printIn()
public class Main {
public static void main(String[] args) {
// Your Program Goes Here
System.out.print(3);
}
}
결과:3
6. 공백을 사이에 두고 출력
1) System.out.print함수를 이용해 " " 문자열 애 두 값을 공백을 사이에 두고 출력
public class Main {
public static void main(String[] args) {
// Your Program Goes Here
System.out.print(3 + " " + 5);
}
}
결과 : 3 5
'자바' 카테고리의 다른 글
[JAVA] 반복문 (0) | 2022.11.18 |
---|---|
[JAVA] 조건문 (0) | 2022.11.14 |
[JAVA] 백준 기초공부 1 (0) | 2022.11.12 |
[JAVA] 여러 가지 연산자 (1) | 2022.11.12 |
[JAVA] 변수와 자료형 (0) | 2022.11.12 |