Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- constantnumber
- Hashtable
- concreteclass
- override
- run()
- class
- reference
- Polymorphism
- 생성자
- hamobee
- overload
- super
- string
- Vector
- value
- fuction
- object
- Eureka
- MSA
- start()
- 객체형변환
- methodArea
- hashCode
- garbagecollection
- 콘크리트클래스
- arguments
- abstractclass
- 추상클래스
- ALTER
- eclipse
Archives
- Today
- Total
뇌운동일지
[JAVA12] Singleton, final, 변수유효범위 본문
Singleton
: 영역은 하나인데 그 영역을 사용하는 것이 2개 이상인 경우
장점) memory를 획기적으로 줄여쓸 수 있다.
단점) 이전의 상태로 돌아갈 수 없다
동일한 영역을 사용하기 때문에 혼선이 생길 수 있음.
-> 무상태의 순차적처리를 할 때 주로 사용.
class SampleClass {
public static SampleClass sc = null;
public static SampleClass getInstance () {
if(sc == null) {
sc = new SampleClass();
}
return sc;
}
singleton을 만드는 방법
객체는 1개만 만들어짐.
final
: 바꿀 수 없는
변수, 메소드, 클래스에 붙을 수 있다
변수 -> 상수만들때
final int a = 10;
메소드 -> overrriding 불가
클래스 -> 상속 불가, final이 붙은 클래스는 더 이상 분할을 시킬 수 없음. 말단 클래스
변수유효범위
클래스변수 : 어디서든 사용가능
전역변수 : 클래스 안에서 사용가능
지역변수 : 메소드 안에서만 사용가능
기본형, 배열형, 객체형
'JAVA' 카테고리의 다른 글
[JAVA14] 접근제한자(Access Modifier), 상속(inheritance) (0) | 2020.03.19 |
---|---|
[JAVA13] String (0) | 2020.03.18 |
[JAVA11] 클래스(class), 객체(object), 인스턴스(instance) (0) | 2020.03.17 |
[JAVA10] 메모리 운영(Method Area, Heap, Stack), garbage collection (0) | 2020.03.17 |
[JAVA09] call by value VS call by reference (0) | 2020.03.16 |
Comments