0
for(int i=0; i<n; i++) {
    System.out.println("Enter Employee "+(i+1)+" Details:");
    System.out.flush();
    System.out.println("Enter the FirstName");
    String f=sc.nextLine();
    System.out.println("Enter the LastName");
    String l=sc.nextLine();
    System.out.println("Enter the Mobile");
    String m=sc.nextLine();
    System.out.println("Enter the Email");
    String e=sc.nextLine();
    System.out.println("Enter the Address");
    String a=sc.nextLine();
    Employee x=new Employee();
    x.setDetails(f, l, m, e, a);
    E.add(x);   
}

that was the loop, E is an Arraylist of class Employee. While entering the 1st employee details the firstname field remains empty. I can't understand why is it happening the following output

Community
  • 1
  • 1
MrGeek
  • 1
  • 1

0 Answers0