-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmp.java
More file actions
32 lines (31 loc) · 920 Bytes
/
Emp.java
File metadata and controls
32 lines (31 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class Address {
String city,state,country; //global variable
Address(String city, String state, String country)
{ //local variable
this.city = city;
this.state = state;
this.country = country;
}
}
//------------------------------
public class Emp {
int id;
String name;
Address address1;
Emp(int id, String name,Address address) {
this.id = id;
this.name = name;
address1=address;
}
void display()
{
System.out.println(id+" "+name);
System.out.println(address1.city+" "+address1.state+" "+address1.country);
}
public static void main(String[] args)
{
Address address2=new Address("gzb","UP","india");
Emp e=new Emp(111,"varun",address2);
e.display();
}
}