* 변수의 유효범위(scope)
  - 해당 변수를 사용할수 있는 범위 또는 공간, 지역
  - 멤버변수의 유효범위-해당클래스내에서 사용가능
  - 지역변수의 유효범위
    . 해당메소드내에서만 사용가능
    . 메소드안으로 들어올때 메모리 할당되고
    . 메소드밖으로 나가면서 메모리 삭제된다

 

 

파일명 : ScopeEx1.java

 

package oop2;

class Score
{
    String name;
    int kor;
    int eng;
    public Score() {}
   
    public Score(String name, int kor, int eng) {
        this.name = name;
        this.kor = kor;
        this.eng = eng;
    }

    void prn()
    {
        System.out.print(name+" ");
        System.out.print(kor+" ");
        System.out.print(eng+" ");
        System.out.println();
    }
    void calc()
    {
        int aver;
        aver=kor+eng/2;
    }

}

public class ScopeEx1 {

    public static void main(String[] args) {
        Score score=new Score("무궁화",50,70);
    }

}

'..열심히 공부하세.. > JAVA 문법' 카테고리의 다른 글

[21] static 예약어  (0) 2012.04.27
[20] this, this()  (0) 2012.04.26
[18] 생성자 함수  (0) 2012.04.26
[17] 메소드 오버로딩  (0) 2012.04.25
[16] 메소드호출방식  (0) 2012.04.24

+ Recent posts