I'm trying to get from Node of class String but the compiler cannot find the Variable. I would appreciate your help.
Student class:
public class Students {
private int[] marks;
private String name;
public Students(String name, int[] marks) {
this.name = name;
marks = new int[5];
for (int i = 0; i < marks.length; i++) {
this.marks[i] = marks[i];
}
}
public int getMarksI(int i) {
return marks[0];
}
public int[] getMarks() {
return marks;
}
public String getName() {
return name;
}
}
The function where the problem:
public double AverageByName(Node < Students > s, String name) {
Node < Students > p = s;
while (p != null) {
if (name == p.getName()) // this is the problem "cannot find symbol p.getName"
{
//
}
p.setNext();
}
return false;
}
In addition to that there is a class of Node and the linked list of the Students class created without a problem in the main.