-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstructor.java
More file actions
43 lines (32 loc) · 949 Bytes
/
constructor.java
File metadata and controls
43 lines (32 loc) · 949 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
42
43
class mymainemployee {
String name;
int id;
public mymainemployee(String myname, int myid) { // constructor me ham ek method defined kae dete hAI
// jiska nam same hota hai MAIN CLASS SE;;;
id = myid; // constructor means constuct karna
name = myname;
}
public mymainemployee() {
id = 45;
name = "varad dhumale";
}
public void setname(String n) {
this.name = n;
}
public String getname() {
return name;
}
public void setid(int i) {
this.id = i;
}
public int getid() {
return id;
}
}
public class constructor {
public static void main(String[] args) {
mymainemployee varad = new mymainemployee("varaddhumale", 20);
System.out.println(varad.getid());
System.out.println(varad.getname());
}
}