-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayofObjects.java
More file actions
36 lines (34 loc) · 920 Bytes
/
ArrayofObjects.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
import java.util.Scanner;
public class ArrayofObjects {
int empid,salary;
String name;
void getdata(int empid,int salary,String name)
{
this.empid=empid;
this.salary=salary;
this.name=name;
}
void display()
{
System.out.println("Empid:"+empid+" salary:"+salary+"Name:"+name);
}
public static void main(String[] args) {
int empid,salary;
String name;
ArrayofObjects[] a=new ArrayofObjects[2];
Scanner sc=new Scanner(System.in);
for(int i=0;i<a.length;i++)
{
a[i]=new ArrayofObjects();
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 (int i=0;i<a.length;i++)
{
a[i].display();
}
}
}