2
for(i=0;i<5;i++)
{
    System.out.println("Enter name for student"+i);
    stud[i].name=v.nextLine();
    System.out.println("Enter number of the student"+i);
    stud[i].regno=v.nextInt();
}

v is the scanner object. I am able to input name for only the 1st object in the array of object. when the loop accesses second object it directly asks me for the regno, not for the name!

Cœur
  • 32,421
  • 21
  • 173
  • 232
Kumaravel Rajan
  • 121
  • 1
  • 8

1 Answers1

1

Change to

System.out.println("Enter name for student"+i);
stud[i].name=v.next();
Hips
  • 244
  • 1
  • 9