728x90
목록JAVA #oop #객체지향프로그래밍 #static #final #singleton (1)
컴공댕이 공부일지

2023.05.08 EC.crew 정모 💙static new로 생성하지 않는 객체/공유변수에 사용하는 키워드 메모리 static 영역에 만들어져 공유된다! 쉽게 말해 다 같이같이 쓰는 건 딱 한번만 생성해두면 되니깐 쓰는 개념이다~ 공기는 함께 공유해서 쓰는 자원이니 굳이 공기를 각각의 객체로 공기1, 공기2 이럴 필요가 없다. 아래 예제를 보면 static을 통한 공유를 더 잘 이해할 수 있다. 🔎 static의 공유적 특성 [ static 사용 x ] public class staticEx { int num = 0; staticEx() { this.num++; System.out.println(this.num); } } public class Sample { public static void main..
기록/EC.crew 정기 모임 정리
2023. 5. 8. 20:41
728x90