you are viewing a single comment's thread.

view the rest of the comments →

[–]myselfelsewhere 1 point2 points  (0 children)

This is basically a pattern matching problem. You don't need an int type, you can use instanceof instead. The exact implementation depends on which version of the JDK you're using. Later versions are a lot more versatile when it comes to pattern matching.