JAVA

변수 유효 범위 체크하기

코린이도이 2023. 9. 19. 10:33

1. Card 클래스의 static 변수 width를 출력하세요.

2. Card 인스턴스의 멤버 변수 number를 출력하세요.

class Card {
	static int width = 10;
    int number = 8;
    int drawCardNumber() {
    	int pnumber;
        pnumber = getRandomInt(1, 13);
        return pnumber;
    }
    private static int getRandemInt(int min, int max) {
    	int randInt = (int)(Math.random() * max) + min;
        return randInt;
    }
}

public class Main {
	public static void main(String args[]) {
    	Card c = new Card();
        System.out.println(Card.width);
        System.out.println(c.number);
    }
}