-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChapter15.java
46 lines (32 loc) · 1.29 KB
/
Chapter15.java
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package javastudy;
class Avante {
//클래스 변수
static String company = "현대";
//인스턴스(객체) 변수
String color;
}
public class Chapter15 {
public static void main(String[] args) {
//클래스 변수 사용 : 객체 생성 없이 사용할 경우 클래스명.변수명
System.out.println("Avante 제조사 = " + Avante.company);
System.out.println("-----------------------");
Avante a1 = new Avante();
System.out.println("a1 객체 제조사 = " + a1.company);
System.out.println("a1 객체 색상 = " + a1.color);
System.out.println("-----------------------");
a1.company = "KIA";
Avante a2 = new Avante();
System.out.println("a2 객체 제조사 = " + a2.company);
System.out.println("a2 객체 색상 = " + a2.color);
System.out.println("-----------------------");
//a1.company = "KIA";
Avante a3 = new Avante();
System.out.println("a3 객체 제조사 = " + a3.company);
System.out.println("a3 객체 색상 = " + a3.color);
System.out.println("-----------------------");
Avante a4 = new Avante();
System.out.println("a4 객체 제조사 = " + a4.company);
System.out.println("a4 객체 색상 = " + a4.color);
System.out.println("-----------------------");
}
}