[JAVA] 1. 자바의 특징

최재원's avatar
Feb 03, 2025
[JAVA] 1. 자바의 특징

1. 객체 지향 프로그램

  • 객체는 상태를 가지고 있다
  • 상태는 행위를 통해 변경한다
notion image

2. 클래스 이름 규칙

  • 규칙 : 첫글자는 대문자
public class Var01 { // 1. 클래스 이름 (오브젝트)

3. 메서드

public static void main(String[] args) { // 2. 메서드 (행위) 3. main (메서드 이름) }
(){}

4. java 실행

notion image
 

1. 자바 파일 생성

src/.java
notion image

2. 클래스 파일 생성

out/.class
notion image

3. static 찾기

public class Var01 { // 1. 클래스 이름 (오브젝트) public void main(String[] args) { // 2. 메서드 (행위) 3. main (메서드 이름) int n1 = 10; System.out.println(n1); } }
notion image
main 메서드가 static이 아니라고 에러가 발생
public class Var01 { // 1. 클래스 이름 (오브젝트) public static void main(String[] args) { // 2. 메서드 (행위) 3. main (메서드 이름) int n1 = 10; System.out.println(n1); } }
static을 추가 후
notion image
정상 작동

4. main 실행

package ex01; public class Var01 { // 1. 클래스 이름 (오브젝트) public static void main2(String[] args) { // 2. 메서드 (행위) 3. main (메서드 이름) int n1 = 10; System.out.println(n1); } }
notion image
main 메서드를 찾을 수 없다고 에러가 발생
package ex01; public class Var01 { // 1. 클래스 이름 (오브젝트) public static void main(String[] args) { // 2. 메서드 (행위) 3. main (메서드 이름) int n1 = 10; System.out.println(n1); } }
main이름을 가진 메서드를 만듦
notion image
정상 작동

5. 자바의 생명 주기

main 메서드의 시작부터 끝까지
public class Var01 { // 1. 클래스 이름 (오브젝트) public static void main(String[] args) { // 2. 메서드 (행위) 3. main (메서드 이름) int n1 = 10; double n2 = 10.5; boolean n3 = true; // false char n4 = 'A'; System.out.println(n1); // 모니터에 Bytestream을 연결해서 출력 System.out.println(n2); System.out.println(n3); System.out.println(n4); } }

6. 실행 파일 위치 열기

notion image
Share article

jjack1