We started to learn classes and i created this method :
Student is my class.the problem is that the output looks like that:"console":public static Student[] getStudentArray(Student[] arr){ Scanner s=new Scanner(System.in); String Name;float Avg; for (int i=0;i<arr.length;i++){ System.out.println("name?"); Name=s.nextLine(); System.out.println("avg?"); Avg=s.nextFloat(); Student temp=new Student(Name,Avg); arr[i]=temp; } return arr; }
How many students?
2
name?
john
avg?
20
name?
avg?
then as you can see it goes name?avg? and stuck.what have i done wrong?