I've created a class called Student which will contain information about students.
public class Student {
private int totalPoint;
private int antalKurser;
private String program;
// here is constructor and get/set methods
}
I'm also trying to create a ArrayList from that class and from what I understand i should write:
public class createArrayList {
ArrayList<Student> studentList new ArrayList<>();
}
However Netbeans gives me an error and if I hover the line it says ';' expexted but I'm positive I have written that (above snippet is copy-pasted). When I run the code it says "compiled with errors" but still runs.
Found somewhere else I also could write:
ArrayList<Class> studentList = new ArrayList<>();
But then how does the application know which class it should create a list from?
The class Student is in another javafile but is in the same package. What am I missing?
=? You really need to learn the basic syntax. You can't just copy-paste code without understanding what you're doing.ArrayList<Student> studentList = new ArrayList<>();you need the =ArrayList<Student> studentList = new ArrayList<>();If you use java 7 though you need to doArrayList<Student> studentList = new ArrayList<Student>();