Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ArrayList of Objects compile error

807606Feb 20 2007 — edited Feb 20 2007
hi all,

i am getting a weird error "constructor Person() not found" in the Student class.... help neone ??

public class Person {
String fName;
String lName;
public Person (String firstName, String lastName) {
fName = firstName;
lName = lastName;
}
/** Retruns the person's name in the format: lastName, firstName.
* (i.e. the last and first names with a comma between them.)
*/
public String toString() {
return (this.lName+","+this.fName);
}
}

import java.util.ArrayList;

public class Student extends Person {
private static ArrayList<Student> students = new ArrayList<Student>();
private ArrayList<Mark> marks = new ArrayList<Mark>();

/** Constructor for Student adds the new Student to the list of
* all students.
*/
public Student(String firstName, String lastName) { //<-- gives me error here
students.add(new Person(firstName, lastName));
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 20 2007
Added on Feb 20 2007
3 comments
153 views