> As others mentioned, there is an implicit class here in play.
The same strategy is also followed by C# with their top-level statements. And yes, it's syntactic sugar.
https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals...
The same strategy is also followed by C# with their top-level statements. And yes, it's syntactic sugar.
https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals...
Basically, imagine a `class Temporary4738 {` and `}` written above and below the .java file's content, that's roughly how it will behave.
It not having a fixed name is deliberate, so if you decide to build a bigger system you won't use this mechanism in a hard to maintain way, and also it needed a good semantic model for "top-level" variables/fields.
But with this implicit class model, top-level definitions are just fields of the class.