java instanceof ,isInstance(),isAssignableFrom之前的差异

 

 

public class ItemQuery {

    private Set<String> tagSet;
    private Set<Blog>   blogs;
    private Float       minPrice;
    private Float       maxPrice;
    private int         page;
    private int         pageSize;
 
 ItemQuery item = new ItemQuery();
        item.tagSet = new HashSet<String>();

        Class type = item.tagSet.getClass();
        System.out.println(Collection.class.isAssignableFrom(type));
        System.out.println(type.isInstance(java.util.Set.class));
        boolean r = type.equals(Set.class);
        System.out.println(r);
        System.out.println(type);
 

你可能感兴趣的:(instanceof)