[ACCEPTED]-object is an instance of class (java)-instance
if (object instanceof RoomBooking) ...
And an interesting read
There is also the
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)
More Related questions