๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ“œ ์ž๋ฐ” Java

JAVA(์ž๋ฐ”) - ์ ˆ์ฐจ์ง€ํ–ฅ๊ณผ ๊ฐ์ฒด์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ

by Meteora_ 2021. 1. 26.
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

๋Œ“๊ธ€