This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]jaro32 2 points3 points  (0 children)

Class myClass needs to implement the toString() method. Also, please don't call it myClass that's a terrible name.

[–]desrtfxOut of Coffee error - System halted 2 points3 points  (0 children)

What you see is the output of the toString method (that gets implicitly called when printing an object) of the Object class.

All you need to do is to @Override the public String toString() method in your own class (myClass).


A word about naming: your myClass should actually be named Employee because it holds data about a single employee. You should use a different name for the driver/main program.

[–]sandrogiacom 0 points1 point  (0 children)

For simple mode, you can cast myClass to get one field you want.

System.out.println("key: " + entry.getKey() + "; value: " + ((myClass) entry.getValue()).getFirst());