forked from icterguru/JavaProgrammingA2Z
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaBeanEx01.java
More file actions
48 lines (37 loc) · 804 Bytes
/
Copy pathJavaBeanEx01.java
File metadata and controls
48 lines (37 loc) · 804 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
44
45
46
47
48
package abcPackage;
/* JavaBeanEx01.java */
/* Use of JavaBean */
import java.io.Serializable;
class Employee implements Serializable{
private int id;
private String name;
static float salary;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
public class JavaBeanEx01 {
public static void main(String args[]){
Employee e =new Employee();//object is created
e.setId(101);
e.setName("Mahdi Munim");
System.out.println(e.getId());
System.out.println(e.getName());
e.salary = 100;
// e.getId();
// e.getName();
//
// e.setName("Mahdi Munim");//setting value to the object
//
// System.out.println(e.getName());
}
}