I work with a List where it saves the data of the database. But when I exucute I get this
[domein.Spel@bddc6, domein.Spel@b0cf230]
You're currently printing the Spel
object reference and it will use toString
method. Since you haven't overridden it, it will use Object#toString
.
You have two approaches to solve this problem:
Override
toString
method inSpel
class:@Override public String toString() { //assuming this class has Naam and aantalRondes fields //replace by the real fields in your class return "{ Naam: " + naam + ", AantalRondes: " + aantalRondes + "}"; }
Go through every element in the
List
and manually print the desired data:for (Spel spel : spelLijst) { //use the format you want/need System.out.println(spel.getNaam() + " " + spel.getAantalRondes()); }