This is all true, but with pattern matching for instanceof you don't need the explicit cast: Object foo = ... if (foo instanceof String s) { System.out.println(s.toLowerCase()) } In this case, the scope of the pattern…
This is all true, but with pattern matching for instanceof you don't need the explicit cast: Object foo = ... if (foo instanceof String s) { System.out.println(s.toLowerCase()) } In this case, the scope of the pattern…