Skip to content

스코프란? +) 생명주기 #3

@azure-553

Description

@azure-553

public class Scope2 {
public static void main(String[] args) {
int m = 10;
for (int i = 0; i <2; i++) { //블록 내부, for문 내
System.out.println("for m =" + m); //블록 내부에서 외부는 접근가능
System.out.println("for i =" + i);
} //i 생존 종료
//System.out.println("main i =" + i); -> 오류, i에 접근 불가
System.out.println("main m =" + m);
}
}

스코프가 무엇인지 설명할 수 있나요? 또 추가로 생명 주기에 대해 공부하는 것도 좋을 것 같아서 자료 두고 갑니다.

https://lemontia.tistory.com/649

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions