Witam stworzyłem sobie listę jednokierunkową, która ma w sobie obiekt klasy Element który wygląda tak
private static final class Element<T>{
private T value;
private Element<T> next;
public Element(T value, Element<T> next){
this.value=value;
this.next=next;
}
public Element(T value){
this(value, null);
}
public T getValue() {
return value;
}
public Element<T> getNext() {
return next;
}
public void setValue(T value) {
this.value = value;
}
public void setNext(Element<T> next) {
this.next = next;
}
}
tworzę listę typu Student( ta klasa wygląda tak):
import java.io.Serializable;
public class Student{
private String imie;
private String nazwisko;
private String nrAlbumu;
private float ocena;
public Student(String imie, String nazwisko, String nrAlbumu, float ocena) {
this.imie = imie;
this.nazwisko = nazwisko;
this.nrAlbumu = nrAlbumu;
this.ocena = ocena;
}
@Override
public String toString() {
return "Student [imie=" + imie + ", nazwisko=" + nazwisko + ", nrAlbumu=" + nrAlbumu + ", ocena=" + ocena + "]";
}
public String getImie() {
return imie;
}
public String getNazwisko() {
return nazwisko;
}
public String getNrAlbumu() {
return nrAlbumu;
}
public float getOcena() {
return ocena;
}
public void setOcena(float ocena) {
this.ocena = ocena;
}
}
I gdy sobie wywołam metodę z klasy Element<T> getValue to powinna mi ona zwrócić obiekt typu student, a tak się nie dzieje zwraca mi obiekt typu student z wywołaną metodą toString chociaż ja jej nie wywołuję. Moje pytanie brzmi czemu ta metoda wywołuje się automatycznie? Jak potrzeba jeszcze jakiś kawałek kodu to napiszcie to dodam, nie chciałem zaśmiecać zbędnym kodem. Z góry dziękuję za pomoc :)