Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01B38FGKKam5SCGgwgduVAh3
27 lines
1.0 KiB
Plaintext
27 lines
1.0 KiB
Plaintext
# _ (unnamed variables and patterns) and compact source files with instance main()
|
|
|
|
$ javac UnnamedVariables.java (JDK 21, no flag)
|
|
<repo>/lanes/src/UnnamedVariables.java:12: error: unnamed variables are a preview feature and are disabled by default.
|
|
if (o instanceof Point(int x, _)) {
|
|
^
|
|
(use --enable-preview to enable unnamed variables)
|
|
1 error
|
|
exit=1
|
|
|
|
$ javac UnnamedVariables.java (JDK 25, no flag)
|
|
exit=0
|
|
$ java UnnamedVariables (JDK 25)
|
|
matched a Point, x = 3, y ignored with _
|
|
caught NumberFormatException without naming it
|
|
|
|
$ java CompactHello.java (JDK 21, no flag)
|
|
<repo>/lanes/src/CompactHello.java:1: error: unnamed classes are a preview feature and are disabled by default.
|
|
void main() {
|
|
^
|
|
(use --enable-preview to enable unnamed classes)
|
|
1 error
|
|
error: compilation failed
|
|
|
|
$ java CompactHello.java (JDK 25, no flag)
|
|
compact source file: no class, no static, no String[] args
|