I have this error when I run my program, and it's driving me crazy because I can't spot the mistake.
Below is my code
public static void addinfo(int range,int start){
String tittle;
Person info[] = new Person[range]; /*Reintiliazing class*/
Scanner kb = new Scanner (System.in); /*Make new scanner for input*/
System.out.println("\n Enter a student tittle (eg. Mr or Mrs)");
tittle = kb.nextLine();
info[0].GetT("Mr");
}
and my Class
class Person {
private String tittle;
private String name;
private String dob;
public void GetT(String s)
{
tittle = s;
}
What i'm trying to do here is to make an array of classes. But it returns Exception (in thread "main" java.lang.NullPointerException). Can anyone please help me?
thanks for reading

New Topic/Question
Reply



MultiQuote




|