Get a possible instance / type of object

I have a problem that this object can be one of several different objects (for example, files in a directory that can be sound, images, text, ...) Is there any way to find out the type of object next to the instanceof operator? Couse, which will result in an endless if-then line ...

+7
java
source share
1 answer

foo.getClass() gets a java.lang.Class object describing the class of the object.

+12
source share

All Articles