public class Address
{
String city,state,country;
public Address(String city,String state,String country)
{
this.city=city;
this.state=state;
this.country=country;
}
}
class Emp
{
int id;
String name;
Address address;
public Emp(int id,String name,Address address)
{
this.id=id;
this.name=name;
this.address=address;
}
void display(){
System.out.println(id+""+name);
System.out.println(address.city+""+address.state+""+address.country);
}
public static void main(String[]args)
{
Address address1=new Address("noida","Utter pardesh","India");
Address address2=new Address("Gorakhpur","Uttar pardesh","India");
Emp e=new Emp(111,"shashi",address1);
Emp e2=new Emp(112,"ravi",address2);
e.display();
e2.display();
}
}
{
String city,state,country;
public Address(String city,String state,String country)
{
this.city=city;
this.state=state;
this.country=country;
}
}
class Emp
{
int id;
String name;
Address address;
public Emp(int id,String name,Address address)
{
this.id=id;
this.name=name;
this.address=address;
}
void display(){
System.out.println(id+""+name);
System.out.println(address.city+""+address.state+""+address.country);
}
public static void main(String[]args)
{
Address address1=new Address("noida","Utter pardesh","India");
Address address2=new Address("Gorakhpur","Uttar pardesh","India");
Emp e=new Emp(111,"shashi",address1);
Emp e2=new Emp(112,"ravi",address2);
e.display();
e2.display();
}
}
0 comments:
Post a Comment