/*here employee is POJO class
POJO = "Plain Old Java Object"
POJO class contain only getter and setter methods*/
class Employee
{
private int empid;
private String empname;
private float empsalary;
public int getEmpid()
{
return empid;
}
public void setEmpid(int empid)
{
this.empid = empid;
}
public String getEmpname()
{
return empname;
}
public void setEmpname(String empname)
{
this.empname = empname;
}
public float getEmpsalary()
{
return empsalary;
}
public void setEmpsalary(float empsalary)
{
this.empsalary = empsalary;
}
}
public class EmployeeMain
{
public static void main(String[] args)
{
Employee employee1 = new Employee();
Employee employee2 = new Employee();
Employee employee3 = new Employee();
employee1.setEmpid(10001);
employee1.setEmpname("Simran Singh");
employee1.setEmpsalary(30000);
System.out.println("Id : " + employee1.getEmpid());
System.out.println("Name : " + employee1.getEmpname());
System.out.println("Salary : " + employee1.getEmpsalary());
System.out.println("\n");
employee2.setEmpid(10002);
employee2.setEmpname("Rajat");
employee2.setEmpsalary(30000);
System.out.println("Id : " + employee2.getEmpid());
System.out.println("Name : " + employee2.getEmpname());
System.out.println("Salary : " + employee2.getEmpsalary());
System.out.println("\n");
employee3.setEmpid(10003);
employee3.setEmpname("Raghav");
employee3.setEmpsalary(30000);
System.out.println("Id : " + employee3.getEmpid());
System.out.println("Name : " + employee3.getEmpname());
System.out.println("Salary : " + employee3.getEmpsalary());
}
}
POJO = "Plain Old Java Object"
POJO class contain only getter and setter methods*/
class Employee
{
private int empid;
private String empname;
private float empsalary;
public int getEmpid()
{
return empid;
}
public void setEmpid(int empid)
{
this.empid = empid;
}
public String getEmpname()
{
return empname;
}
public void setEmpname(String empname)
{
this.empname = empname;
}
public float getEmpsalary()
{
return empsalary;
}
public void setEmpsalary(float empsalary)
{
this.empsalary = empsalary;
}
}
public class EmployeeMain
{
public static void main(String[] args)
{
Employee employee1 = new Employee();
Employee employee2 = new Employee();
Employee employee3 = new Employee();
employee1.setEmpid(10001);
employee1.setEmpname("Simran Singh");
employee1.setEmpsalary(30000);
System.out.println("Id : " + employee1.getEmpid());
System.out.println("Name : " + employee1.getEmpname());
System.out.println("Salary : " + employee1.getEmpsalary());
System.out.println("\n");
employee2.setEmpid(10002);
employee2.setEmpname("Rajat");
employee2.setEmpsalary(30000);
System.out.println("Id : " + employee2.getEmpid());
System.out.println("Name : " + employee2.getEmpname());
System.out.println("Salary : " + employee2.getEmpsalary());
System.out.println("\n");
employee3.setEmpid(10003);
employee3.setEmpname("Raghav");
employee3.setEmpsalary(30000);
System.out.println("Id : " + employee3.getEmpid());
System.out.println("Name : " + employee3.getEmpname());
System.out.println("Salary : " + employee3.getEmpsalary());
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.