import java.util.*;
public class Student {
private String [] first;
private String [] last;
private String [] HKID;
private String[] SID;
private int []Exam;
private int num;
Scanner kb= new Scanner(System.in);
public Student (String f, String l, String h, String s, int e, int n){
System.out.println("Please enter number of students:");
n = kb.nextInt();
for(int i=0;i >n; i++){
System.out.println("First name:");
f = kb.next();
first = new String[f];
System.out.println("Last name:");
l=kb.next();
last= new String[l];
System.out.println("HKID:");
h=kb.next();
HKID=new String[h];
System.out.println("SID:");
s=kb.next();
SID=new String [s];
System.out.println("Final exam score:");
e=kb.nextInt();
Exam=new int [e];
}
public String[] getFirst(){return first;}
public String [] getLast(){return last;}
public String [] getHKID(){return HKID;}
public String [] getSID(){return SID;}
public int [] getExam(){return Exam;}
public void setFirst(String [] f){f=first;}
public void setLast(String [] l){l=last;}
public void setHKID(String [] h){h=HKID;}
public void setSID(String [] s){s= SID;}
public void setExam(int [] e){e=Exam;}
}
I am creating a code that first asks user how many students are in the class. From this it asks several details to enter for each student and stored in their respective arrays. Problem: I can't put enter a String variable into my String array. I can't think of any way around this. Please help.
for (int i = 0;i < n; i++)and it should work.