자바/자바의정석-연습문제

자바의정석 연습문제 풀이 6장 6-8

김발자~ 2022. 9. 22. 21:27
반응형

자바의 정석 3판 연습문제 풀이

 

연습문제 파일은 아래 링크에서 다운받을 수 있다

https://github.com/castello/javajungsuk3/tree/master/%EC%97%B0%EC%8A%B5%EB%AC%B8%EC%A0%9C%ED%92%80%EC%9D%B4

 

GitHub - castello/javajungsuk3: soure codes and ppt files of javajungsuk 3rd edition

soure codes and ppt files of javajungsuk 3rd edition - GitHub - castello/javajungsuk3: soure codes and ppt files of javajungsuk 3rd edition

github.com

 

 

http://www.yes24.com/Product/Goods/24259565

 

Java의 정석 - YES24

최근 7년동안 자바 분야의 베스트 셀러 1위를 지켜온 `자바의 정석`의 최신판. 저자가 카페에서 12년간 직접 독자들에게 답변을 해오면서 초보자가 어려워하는 부분을 잘 파악하고 쓴 책. 뿐만 아

www.yes24.com

자바의 정석 저자 남궁성 님이 직접 올려주신 문제다

 


챕터6은 총 24문제로 구성되어 있다


6-8


 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class PlayingCard{
    int kind;    //인스턴스변수 iv
    int num;    //인스턴스변수 iv
    
    static int width;    //class변수(static변수)
    static int height;    //class변수(static변수)
    
    PlayingCard(int k, int n){
        kind = k;    //지역변수 lv
        num = n;    //지역변수 lv
    }
    
    public static void main(String[] args) {    //args: 지역변수 lv
        PlayingCard card = new PlayingCard(1,1); //card: 지역변수 lv
    }
}
cs

 

클래스 블럭 안에 있고 static이 붙으면 클래스변수(static변수)

클래스 블럭 안에 있는데 static이 붙어있지 않으면 인스턴스변수(iv)

메서드(생성자도 포함) 영역 안에 있는 다른 변수 모두 지역 변수(lv)

 

 


 

반응형