- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayofObjects.java
More file actions
Latest commit
36 lines (34 loc) · 920 Bytes
/
Copy pathArrayofObjects.java
File metadata and controls
36 lines (34 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
33
34
35
36
importjava.util.Scanner;
publicclassArrayofObjects {
intempid,salary;
Stringname;
voidgetdata(intempid,intsalary,Stringname)
{
this.empid=empid;
this.salary=salary;
this.name=name;
}
voiddisplay()
{
System.out.println("Empid:"+empid+" salary:"+salary+"Name:"+name);
}
publicstaticvoidmain(String[] args) {
intempid,salary;
Stringname;
ArrayofObjects[] a=newArrayofObjects[2];
Scannersc=newScanner(System.in);
for(inti=0;i<a.length;i++)
{
a[i]=newArrayofObjects();
System.out.println("Enter id salary name of employee");
empid=sc.nextInt();
salary=sc.nextInt();
name=sc.next();
a[i].getdata(empid,salary,name);
}
for (inti=0;i<a.length;i++)
{
a[i].display();
}
}
}