class
load
{
String firstname;
String lastname;
int age;
String profession;
load assign(String firstname,String
lastname,int age,String profession)
{
this.firstname = firstname;
this.lastname = lastname;
this.age = age;
this.profession = profession;
return this;
}
load assign(String fn,String ln)
{
firstname = fn;
lastname = ln;
return this;
}
load assign(String fn,String ln,String
prof)
{
firstname = fn;
lastname = ln;
profession = prof;
return this;
}
load assign(String fn,int ag)
{
firstname = fn;
age = ag;
return this;
}
void print()
{
System.out.println(firstname +
" " + lastname + " " + age + " " + profession);
}
public static void main(String args[])
{
load fl = new load();
fl.assign("Naveen","Kumar",23,"Programmer");
fl.print();
fl.assign("Raj","Prabhu");
fl.print();
fl.assign("Chitra","Devi","Analyst");
fl.print();
fl.assign("Nithya",34);
fl.print();
}
}
No comments:
Post a Comment