-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest_S103.java
More file actions
41 lines (27 loc) · 968 Bytes
/
Test_S103.java
File metadata and controls
41 lines (27 loc) · 968 Bytes
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
package Gun47;
class Student{
String name;
public Student(String name){
this.name=name;
}
public Student(){
}
}
public class Test_S103 {
public static void main(String[] args) {
Student[] students = new Student[3];
//hata name den dolayi degil students[0] hic olusturulmadi,yaratilmadi diye yazdirirken nullpoint hatasi verir
//cunku olmayan bir seyi yazdiriyoruz java tanimiyor bilmiyor. Dogmamis cocuga isim vermek gibi.
//students[0] hic yaratilmadi olmayan bir sey.
//NOTE : Baska class i bu sekilde de nesne uretebiliriz.
students[1]=new Student("Richard");
students[2]=new Student("Donald");
for(Student s : students){
System.out.println("" + s.name); //.name
}
//yukarisi ile bu kisim birbirinin aynisi
Student ogr0;
Student ogr1 = new Student("Ismet");
Student ogr2 = new Student("Ayse");
}
}