new to ArrayList and was wondering what I am doing wrong. I keep getting a null pointer exception when trying to addRecord...
import java.util.*;
public class StudentDB {
private List<String> studentDB;
public StudentDB(String db) {
List<String> studentDB = new ArrayList <String>();
studentDB.add("");
}
public void addRecord(String recordAdd) {
studentDB.add(recordAdd);
}
}
public class TestStudentRec {
public static void main (String[] args) {
StudentDB db = new StudentDB("this");
db.addRecord("added record");
System.out.print(db);
}
}