-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetStudent.java
More file actions
25 lines (23 loc) · 612 Bytes
/
GetStudent.java
File metadata and controls
25 lines (23 loc) · 612 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
package com.tyss.finalassessment;
import java.util.ArrayList;
import java.util.Scanner;
public class GetStudent {
public void getStudent(ArrayList<StudentDetails> list,Scanner scanner) throws Exception{
if(list.isEmpty()) {
System.out.println("your list is empty");
return;
}
System.out.println("enter the id");
int id=scanner.nextInt();
int y=0;
for (StudentDetails studentDetails : list) {
if(id==studentDetails.id) {
System.out.println("The student detail\n"+studentDetails);
y++;
}
}
if(y==0) {
System.out.println("This id is not present in the list");
}
}
}