Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication2;
- class Address {
- int postal;
- String street;
- String city;
- String country;
- Address(int p,String s,String c,String co){
- postal = p;
- street = s;
- city = c;
- country =co;
- }
- }
- __________________________________
- class Employee {
- int id;
- String name;
- double salary;
- Address address;
- Employee(int i, String n,double s,Address a){
- id = i;
- name = n;
- salary = s;
- address = a;
- }
- }
- public class JavaApplication2 {
- public static void main(String[] args) {
- Address a = new Address(1234,"king fahad","riyadh","KSA");
- Employee e = new Employee(1,"Saleh",8000,a);
- System.out.println("ID: "+e.id);
- System.out.println("NAME: "+e.name);
- System.out.println("SALARY: "+e.salary);
- System.out.println("POSTAL: "+e.address.postal);
- System.out.println("STREET: "+e.address.street);
- System.out.println("CITY: "+e.address.city);
- System.out.println("COUNTRY: "+e.address.country);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement