2022.10.11
여러 개의 인수 매개변수로 전달
배열 전달
public int sumAll(int[] a) {
int result = 0;
for(int i : a) {
result += i;
}
return result;
}
…
사용
public int sumAll(int ... ds) {
int result = 0;
for (int d : ds) {
result += d;
}
return result;
}
static
static field 와 static method 가 있음
클래스의 모든 객체가 공유
객체 생성없이 클래스 이름만으로 사용 가능
객체 생성 이전에 클래스가 로드될 때 메모리에 올라감
this 사용 불가
사용법
[클래스 이름].정적필드이름
[클래스 이름].정적메소드이름
초기화 블록
싱글톤 패턴