Skip to content

Instantly share code, notes, and snippets.

@ahirschberg
Created December 29, 2016 22:01
Show Gist options
  • Save ahirschberg/21cdd9c05249463748d698c7217291dc to your computer and use it in GitHub Desktop.
Save ahirschberg/21cdd9c05249463748d698c7217291dc to your computer and use it in GitHub Desktop.
import java.util.Set;
import java.util.HashSet;
public class TestTypes {
public static void main(String[] args) {
Class<?> t = Set.class;
Object s = new HashSet<String>();
Object n = new Integer(-1);
System.out.println(t.isInstance(s)); // true
System.out.println(t.isInstance(n)); // false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment