You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RecordPatternsPreview1OK.java 373B

123456789101112131415
  1. public class RecordPatternsPreview1OK {
  2. static void printGenericBoxString1(Box<Object> objectBox) {
  3. if (objectBox instanceof Box<Object>(String s)) {
  4. System.out.println(s);
  5. }
  6. }
  7. static void printGenericBoxString2(Box<String> stringBox) {
  8. if (stringBox instanceof Box<String>(var s)) {
  9. System.out.println(s);
  10. }
  11. }
  12. }
  13. record Box<T>(T t) {}