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 | 29 | 30 |
Tags
- OGNL
- 기본
- 전화걸기
- layout
- Java
- 어노테이션
- AWT
- mybatis
- 이클립스
- Menu
- JSP
- Graphic
- 메소드
- 메서드
- 오버로딩
- Android
- 안드로이드
- oracle
- 생성자
- 예외처리
- 배열
- 클래스
- 국제화
- JavaScript
- 에러페이지
- struts2
- HTML
- paint
- Spring
- Eclips
Archives
- Today
- Total
note
정직 멤버변수와 인스턴스 멤버 변수의 차이점 본문
class StaticTest{//정직 멤버변수와 인스턴스 멤버 변수의 차이점
static int a=10; //클래스(static)에 올라감
int b=20; //heap에 올라감
}
public class StaticTest01 {
public static void main(String[] args){
System.out.println("StaticTest.a->"+StaticTest.a);
StaticTest s1 = new StaticTest();
StaticTest s2 = new StaticTest();
System.out.println("s1.a->"+StaticTest.a+"\t s2.a->" + StaticTest.a);
System.out.println("s1.b->"+StaticTest.a+"\t s2.b->" + s2.b);
//정확한 호출 방법이 아님 StaticTest.a 로 호출해야됨
StaticTest.a=100;
System.out.print("s1.a->" + StaticTest.a);
System.out.println("\t s2.a->"+StaticTest.a);
s1.b=200;
System.out.print("s1.b->" + s2.b);
System.out.println("\t s2.b->"+s2.b);
}
}
StaticTest.a->10
s1.a->10 s2.a->10
s1.b->10 s2.b->20
s1.a->100 s2.a->100
s1.b->20 s2.b->20