real world object
0//Real World Object creation. Reduce the redundancy.
class Employee
{
int empid;
String name;
String job;
Employee(int eid,String en,String ej)
{
empid=eid;
name=en;
job=ej;
}
void Display()
{
System.out.println("\n Employee Id "+empid+" Details");
System.out.println("Employee Id:"+empid);
System.out.println("Employee Name:"+name);
System.out.println("Employee JOb:"+job);
}
}
class CEmployee
{
public static void main(String[] args)
{
Employee e1=new Employee(1,"Smith","Java Developer");
Employee e2=new Employee(2,"John","Java Developer");
Employee e3=new Employee(3,"Scott","java developer");
e1.Display();
e2.Display();
e3.Display();
}
}
OutPut:
Employee Id 1 Details
Employee Id:1
Employee Name:Smith
Employee JOb:Java Developer
Employee Id 2 Details
Employee Id:2
Employee Name:John
Employee JOb:Java Developer
Employee Id 3 Details
Employee Id:3
Employee Name:Scott
Employee JOb:java developer
0 comments: