java_Arr
5
Hi Friend, Try the following code: import java.io.*; import java.util.*; class Employee{ public int id; public String name; public String address; public static int count = 0; public Employee(){} public Employee(int id, String name,String address) { super(); this.id = id; this.name = name; this.address=address; count++; } public int getId() { return id; } public String getName() { return name; } public String getAddress() { return address; } } public class DisplayArrayList { public static void main(String[] args) throws Exception { List<Employee> list = new ArrayList<Employee>(); list.add(new Employee(1, "A","Delhi")); list.add(new Employee(2, "B","Mumbai")); list.add(new Employee(3, "C","Chennai")); list.add(new Employee(4, "D","Kolkata")); System.out.println(" "); System.out.print("Enter Employee Id: "); Scanner input=new Scanner(System.in); int id = input.nextInt(); for (Employee s : list){ if(id == s.getId()) { System.out.println("Name and Address of employee is: "); System.out.print(s.getName()+" " +s.getAddress()); } } } } ---------------------------------------------------------------- String data; String[][] matrix = new String[4][4]; private void readFile() {
Transcript of java_Arr
8/8/2019 java_Arr
http://slidepdf.com/reader/full/javaarr 1/5
8/8/2019 java_Arr
http://slidepdf.com/reader/full/javaarr 2/5
8/8/2019 java_Arr
http://slidepdf.com/reader/full/javaarr 3/5
8/8/2019 java_Arr
http://slidepdf.com/reader/full/javaarr 4/5
8/8/2019 java_Arr
http://slidepdf.com/reader/full/javaarr 5/5