Been working with Java for over a decade now, and for quick, reliable checks, instanceof has always been my go-to.
If you’re trying to java get type of object, using instanceof is one of the most straightforward and widely accepted ways:
public void test(Object value) {
if (value instanceof Integer) System.out.println("This is an Integer");
else if (value instanceof String) System.out.println("This is a String");
else if (value instanceof Float) System.out.println("This is a Float");
}
It plays really well with inheritance and polymorphism. So if you’re dealing with a class hierarchy, instanceof is your safest bet.