[ACCEPTED]-object is an instance of class (java)-instance
There is also the isAssignableFrom
method in Class
.
if(CabinBooking.class.isAssignableFrom(object.getClass())
I prefer the 4 method that @assylias
suggested since it would work 3 even in object == null
while isAssignableFrom
would throw an error if 2 the parameter is null. So you must check 1 that the instance is not null.
if(object instanceof CabinBooking.class)
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.