-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path13_Constructor in java
45 lines (42 loc) · 937 Bytes
/
13_Constructor in java
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
class MyMainEmployee{
private int id;
private String name;
private int salary;
public MyMainEmployee(){
id=78;
name="PM";
}
public MyMainEmployee(String myName, int myId, int mySalary){
id=myId;
name=myName;
salary=mySalary;
}
public String getName() {
return name;
}
public void setName(String n){
name = n;
}
public int setId(int i){
this.id = i;
return i;
}
public int getId(){
return id;
}
public int setSalary(int j){
this.salary=j;
return salary;
}
public int getSalary() {
return salary;
}
}
public class Constructors {
public static void main(String[] args) {
MyMainEmployee gg = new MyMainEmployee("NEWT", 89, 10000);
System.out.println(gg.getId());
System.out.println(gg.getName());
System.out.println(gg.getSalary());
}
}