em có
public class hocsinh {
String Ten;
String GioiTinh;
public void nhapvao(){
Scanner keyboard = new Scanner(System.in);
System.out.println("Nhập vào tên: ");
Ten = keyboard.nextLine();
System.out.println("Nhập vào giới tính: ");
GioiTinh = keyboard.nextLine();
}
public void xuat(){
System.out.printf(" Tên: %s | Giới Tính: ", Ten, GioiTinh);
System.out.println("");
}
}
và
public class TestCom {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int N;
System.out.println("Nhập vào N: ");
Scanner keyboard = new Scanner(System.in);
N = Integer.parseInt(keyboard.nextLine());
hocsinh[] std = new hocsinh[N];
for (int i=1;i <= N; i++){
System.out.println("Nhập vào sinh viên thứ" + i );
std[i] = new hocsinh();
std[i].nhapvao();
}
for (int i=1; i <= N; i++){
std[i].xuat();
}
}
}
các bác xem lỗi ở đâu mà khi chạy nó ra lỗi này
Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 1
at test.com.TestCom.main(TestCom.java:27)