-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConstructor.java
More file actions
41 lines (38 loc) · 902 Bytes
/
Constructor.java
File metadata and controls
41 lines (38 loc) · 902 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
class Employee{
private int id;
private String name;
public Employee(){
id = 0;
name = "Your-Name-Here";
}
public Employee(String myName, int myId){
id = myId;
name = myName;
}
public Employee(String myName){
id = 1;
name = myName;
}
public String getName(){
return name;
}
public void setName(String n){
this.name = n;
}
public void setId(int i){
this.id = i;
}
public int getId(){
return id;
}
}
public class Constructor {
public static void main(String[] args) {
Employee ashvin = new Employee("ProgrammingWithAShvin", 12);
//Employee ashvin = new Employee();
// ashvin.setName("CodeWithASHVIN");
// ashvin.setId(34);
System.out.println(ashvin.getId());
System.out.println(ashvin.getName());
}
}