-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstructor_person.java
More file actions
40 lines (35 loc) · 1.14 KB
/
Copy pathconstructor_person.java
File metadata and controls
40 lines (35 loc) · 1.14 KB
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
package oop.basic;
public class constructor_person {
// private , public , protected , defaul;
private int id;
private String name,gender;
private float height;
// create defaul contructor
public constructor_person(){
id = 007;
name = "SereyPanha";
gender = "Male";
height = 1.49f;
}
// create contructor with parameter
public constructor_person(int id,String name, String gender,float height){
this.id = id;
this.name = name;
this.gender = gender;
this.height = height;
}
public void Ouput(){
System.out.println(" ID :"+id);
System.out.println(" Nmae :"+name);
System.out.println(" Gender :"+gender);
System.out.println(" Heigth :"+height+"m");
}
public static void main(String[] args) {
System.out.println("Defaul contructor ");
constructor_person con = new constructor_person();
con.Ouput();
System.out.println("contructor with parameter");
constructor_person con1 = new constructor_person(005,"kaka","female",180f);
con1.Ouput();
}
}