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!

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

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 :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.