public static boolean sameClass(final Object first,final Object second){
  return first.getClass() == second.getClass();
}

public static boolean sameClass ( final Object first , final Object second ) { return first . getClass ( ) == second . getClass ( ) ; }
this method checks if two objects are of the same class .
