Skip to content

Check whether Java 12-15 features force HS linters to produce errors / warnings and update the linters if it's required #52

@swsms

Description

@swsms

Stepik is going to update the Java version in Autumn and HS content team started writing content for Java 15 features. However they aren't sure whether the new content will have errors produced by linters cause they may not know about the new features.

There are some features from new versions of Java we'd like you to check:

Text blocks

String htmlWithJava13 = """
              <html>
                  <body>
                      <p>Hello, world</p>
                  </body>
              </html>
              """;

Switch expressions

String result = switch(new Random().nextInt(5)){
    case 1 -> "a";
    case 2 -> "b";
    default -> "unknown";
};

Records

record Person(String name, String surname) {

    public Person {
        if (name == null || surname == null) {
            throw new RuntimeException("Name and surname is mandatory!");
        }
    }
}

Pattern Matching For InstanceOf

if (obj instanceof String s) {
    System.out.println(s.contains("hello"));
}

Sealed Classes

public sealed interface Drivable permits Vehicle {
    void accelerate();
}

public abstract non-sealed class Vehicle implements Drivable {
    public abstract void configure();
}

the link
https://medium.com/blue-harvest-tech-blog/what-happened-to-java-after-8-java-15-and-the-future-8a005edcc013

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions