Java syntax highlighting sample
This post exists to verify that fenced java blocks are syntax highlighted correctly on the site.
package com.example.blog;
import java.time.Instant;
import java.util.List;
public final class SyntaxHighlightingDemo {
private SyntaxHighlightingDemo() {
}
public static void main(String[] args) {
List<String> frameworks = List.of("Spring", "Quarkus", "Micronaut");
frameworks.stream()
.map(String::toUpperCase)
.forEach(name -> System.out.println(name + " @ " + Instant.now()));
}
}
And a shorter snippet with control flow:
public String classifyScore(int score) {
if (score >= 90) {
return "excellent";
} else if (score >= 75) {
return "good";
}
return "keep going";
}