-- Binding the data along with their corresponding functionalities.
-- we achieve the concept of encapsulation only by declaring all the variables as private and providing public setter,getter methods
-- javaBeans are used to transfer the data. so, java beans are also known as "data transfer objects" (DTO).
this is used to set the value and get the values.so,it is known as "value object"(VO)
example :
public class Employee {
private int id;
private String name;
private String addr;
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 String getAddr() {
return addr;
}
public void setAddr(String addr) {
this.addr = addr;
}
}
package com.pointred.encaptest;
public class Test {
public static void main(String[] args) {
Employee em = new Employee();
em.setId(4);
em.setName("bala");
em.setAddr("bangalore");
System.out.println("values are "+em.getName()+" " +em.getAddr() +" "+em.getId());
}
}
-- we achieve the concept of encapsulation only by declaring all the variables as private and providing public setter,getter methods
-- javaBeans are used to transfer the data. so, java beans are also known as "data transfer objects" (DTO).
this is used to set the value and get the values.so,it is known as "value object"(VO)
example :
public class Employee {
private int id;
private String name;
private String addr;
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 String getAddr() {
return addr;
}
public void setAddr(String addr) {
this.addr = addr;
}
}
package com.pointred.encaptest;
public class Test {
public static void main(String[] args) {
Employee em = new Employee();
em.setId(4);
em.setName("bala");
em.setAddr("bangalore");
System.out.println("values are "+em.getName()+" " +em.getAddr() +" "+em.getId());
}
}
No comments:
Post a Comment