forked from princekumar-code/HacktoberFest2020-1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayOfObject in Java
More file actions
41 lines (34 loc) · 747 Bytes
/
ArrayOfObject in Java
File metadata and controls
41 lines (34 loc) · 747 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
33
34
35
36
37
38
39
40
41
// Write a program of array of object in Java
//package practice;
import java.lang.Object;
public class ArrayOfObjects {
public static void main(String[] args)
{
Employee e1 = new Employee();
Address ad = new Address();
Object obj3[] = {e1,ad};
System.out.println("Dissimiliar Elements of Array of Objects...");
for(Object o1 : obj3)
{
System.out.println(o1);
}
}
}
class Employee
{
String nam = "Jiya";
String id = "A1234";
@Override
public String toString()
{
return nam+" : "+id;
}
}
class Address
{
String hno = "123 New Delhi";
public String toString()
{
return hno;
}
}