0

Hi, I am starting out with linkedlists and would like to know about using another class in a linkedlist.
Here is what I am trying to do:

LinkedList<Student> list = new LinkedList<Student>();
list.add(new Student("Name", 92, 87, 81));

I have no idea what the student class would look like! Would anyone mind writing a simple student class for me? (by the way, the numbers are marks). I tried making a class called Student and I put in a a method called Student, but I am really lost as to how to use a class in a linkedlist. Thanks in advance!

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by david cashin
0

The code that you written would work, provided that you have a Student. class. Usually first you write the Student class. So in a separate file on its own, create a Student class with any attributes, methods and constructors you want. Then create student instances and put them in the list:

public class Student {
   // attributes
   
   public Student() {

  }

  //  and more
}

Take a look some tutorials about objects

0

The code that you written would work, provided that you have a Student. class. Usually first you write the Student class. So in a separate file on its own, create a Student class with any attributes, methods and constructors you want. Then create student instances and put them in the list:

public class Student {
   // attributes
   
   public Student() {

  }

  //  and more
}

great thanks alot, that was much easier than i thought :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.