728x90
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/*
์ฝ์ Object Oriented Programming (๊ฐ์ฒด ์งํฅ ํ๋ก๊ทธ๋๋ฐ)
class ํด๋์ค๋ช
{
๋ณ์์ ์ ์ธ
๋ฉ์๋ ์ ์ธ
}
*/
/*
์ฃผ์ฌ์ ๊ฒ์
number ->2
random ->2
์ฃผ์ฌ์ ->2
number
random
*/
int number[] = new int[5];
int lang[] = new int[5]; //๋ช๋ช
์ธ์ง ๋ชจ๋ฅด๋๊น ๋ฐฐ์ด๋ก ์ก์๋์
int math[] = new int[5];
int eng[] = new int [5];
String name[] = new String[5];
number[0] = 1;
/*
student st[] = new student[5]; // ๊ฐ์ฒด์์ฑ ์๋ ๋ฐฐ์ด์์ฑ
student st1, st2 , st3, st4, st5;
for (int i = 0; i < st.length; i++) {
st[i] = new student(); // ํ๋ํ๋ ๋ค ๋์ ํ ๋นํด์ผํจ
}
st[0].number=1;*/
MyClass cls1 = new MyClass();
cls1.x=1;
cls1.y=2;
cls1.z=3;
cls1.method();
MyClass cls2 =null;
cls2 = new MyClass();
cls2.x=3;
cls2.y=4;
cls2.z=5;
cls2.method();
//student st = new student();
//st.number=1; // ๋ํธ๋ฅผ ํตํด์ ์ ๊ทผํ ์์๋ค .
// ํด๋์ค๋ช
, ๋ณ์(์คํ, ๊ฐ์ฒด, ์ธ์คํด์ค), ๋์ ํ ๋น, ํ์์ญ์ ์๋ค.
// st -> ์ค ๋ฉ๋ชจ๋ฆฌ ์์ญ์ ์ฌ๋ผ๊ฐ๋ ๊ฒ , object
}
}
class Student{
//๋ฉค๋ฒ๋ณ์
int lang;
int math;
int eng;
int number;
String name;
}
class MyClass{
//๋ณ์
int x, y, z;
//๋ฉ์๋
void method() {
System.out.println("MyClass method() ํธ์ถ");
}
}
|
cs |
๋๊ธ