-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmpClass.java
More file actions
57 lines (46 loc) · 971 Bytes
/
EmpClass.java
File metadata and controls
57 lines (46 loc) · 971 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
42
43
44
45
46
47
48
49
50
51
52
53
54
import java.util.Scanner;
class Employee
{
String name;
int empNo;
int PhNo;
void read()
{
try (Scanner sc = new Scanner(System.in)) {
System.out.print("Enter the name: ");
name = sc.nextLine();
System.out.print("Enter the Employee No: ");
empNo = sc.nextInt();
System.out.print("Enter the Employee phone No: ");
PhNo = sc.nextInt();
}
}
void display()
{
System.out.println("Employee name: "+name);
System.out.println("Employee no: "+empNo);
System.out.println("Phone Number: "+PhNo);
System.out.println();
System.out.println();
}
}
public class EmpClass
{
public static void main(String args[])
{
Employee obj[] = new Employee[5];
for(int i=0;i<5;i++)
{
obj[i] = new Employee(); // constructor initialization ...
}
for(int i=0;i<5;i++)
{
obj[i].read();
}
for(int i=0;i<5;i++)
{
obj[i].display();
System.out.println();
}
}
}