Alright, I'm not gonna' lie. This is probably a silly problem for all you veterans, but I'm very (VERY) fresh in the art of Java code-writing, so forgive the noobishness.
I'm writing an equals()-method for my program which looks like this:
public boolean equals(Object objekt) { Pasientjournal middlertidig = (Pasientjournal)objekt; if (this.getID() == middlertidig.getID()) return true; else return false; }
But whenever i try to actually compare anything i get tossed a:
java.lang.ClassCastException: java.lang.Integer cannot be cast to Pasientjournal at Pasientjournal.equals(Pasientjournal.java:35) ... ... ...
Now, like i said, I'm rather fresh here, so could someone toss me a short explanation of what's wrong?
Or maybe just toss me the correct version of my faulty code?
("middlertidig" is btw just my native tongue for "temporary")
Thanks so much for the help guys!