Everything in java is a class, not sure what you mean.
Personally, it's nice from an operations perspective. Makes debugging performance problems a lot easier.
Then it's "old Java", not "modern java" ?
Are you thinking of JavaScript? In Java you can’t even write hello world without a class.
Soon you will: https://openjdk.org/jeps/8302326
> I thought "modern Java" means classless ?
Nope.
> Why do i need to put some code inside another superficial class here ?
Which class is the superficial class?
Are you thinking of records?
It's still a class :p
Only if by "modern Java" you mean Kotlin.
C# has top-level functions and even top-level code these days, but it evolves a lot faster.
When Kotlin ships with their own JVM replacement, we might think about calling it "modern" Java.
I did not mean suggest that it is one. But many people outside of the ecosystem seem to treat it this way after Google started promoting it, which would explain OP's confusion.
"Modern Java" is not formally defined, but most people seem to associate it with Java for Microservices (small runtimes instead of ancient Java EE), functional programming, streams, reactive programming and generally using newer (Java 8+) language constructs.
There's a lot more to it than obsessing over a single line of boilerplate code...
Why do i need to put some code inside another superficial class here ?