[Student 클래스 소스]
public class Student {
static int serialNum; // 정정 맴버변수 선언
String name;
String major;
Student(String name, String major)
{
this.name = name;
this.major = major;
serialNum++;
}
static int getSerial( )
{
return serialNum;
}
}
[StaticTest 클래스 소스]
public class StaticTest {
public static void main(String[ ] args)
{
@SuppressWarnings("unused")
Student s1 = new Student("소프트웨어공학", "이영미");
@SuppressWarnings("unused")
Student s2 = new Student("컴퓨터통신", "박선영");
@SuppressWarnings("unused")
Student s3 = new Student("인공지능", "김미화");
System.out.println("serialNum 변수: " + Student.serialNum);
System.out.println("인스턴스의 개수:" + Student.getSerial());
}
}
static final 차이점은 "새롭게 시작하는 자바 프로그래밍" 이주진, 김홍섭 지음[개정판] p261~p266에 자세히 나와 있습니다. 읽고 참조 부탁드립니다. 다음 진도 진행해야 합니다. 고고싱
static과 final에 대체 무슨 부분집합이 있는건지 ,,, final은 상속금지 키워드고, static은 각종 정적 변수, 멤버나 파일종속 키워드아님?
포봄이 뭐죠 ?