코딩공부/Java

06. 자바 가상머신 (Java virtual Machine)

잉옐잉 2021. 9. 12. 00:35

자바 가상머신(JVM)

자바의 실행 엔진이다.

자바코드를 운영체재에 맞게 재 컴파일을 한 후 실행 가능하게 해준다.

 

JVM의 절차

1. 해당클래스를 현재 디렉토리에서 찾는다.

2. 찾고나서 클래스 내부에 static 키워드가 있는 메서드를 메모리로 코딩한다.

3. static zone에서 메서드를 실행한다.

4. stack Area가 비어있으면 프로그램이 종료된 것이다.

 

 


public class TPC08 {

	public static void main(String[] args) {
		int a = 30;
		int b = 24;
		int v = add(a,b); // static method call
		System.out.println(v);
	}
	public static int add(int a, int b) {
		int sum = a+b;
		return sum;
	}
}
public class TPC09 {

	public static void main(String[] args) {
		int a=56;
		int b=44;
		
		TPC09 tpc = new TPC09(); //heap area에 객체생성
		int v = tpc.sum(a,b);
		System.out.println(v);

	}
	public int sum(int a, int b) {
		int v=a+b;
		return v;
	}

}

'코딩공부 > Java' 카테고리의 다른 글

07. 객체 생성 과정  (0) 2021.09.17
05. 변수와 메서드  (0) 2021.07.29
04. 배열(Array)  (0) 2021.07.21
03. PDT VS UDDT  (0) 2021.07.20
02. 변수, 자료형, 할당  (0) 2021.07.20