Skip to content

Instantly share code, notes, and snippets.

@gyselph
Created January 15, 2021 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gyselph/311cf7bdf0bf030fac1c6fce21c9fb75 to your computer and use it in GitHub Desktop.
Save gyselph/311cf7bdf0bf030fac1c6fce21c9fb75 to your computer and use it in GitHub Desktop.
Java 7 to 15: new instanceof
Object obj = new String("hello");
if (obj instanceof String mystr) {
System.out.println("String length: " + mystr.length());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment