C# has this: https://learn.microsoft.com/en-us/dotnet/csharp/language-ref...
C# has this: https://learn.microsoft.com/en-us/dotnet/csharp/language-ref...
This is only syntactic sugar to allow using object initializers to initialize specific member varabiles of a class instance instead of simply using a constructor and/or setting member variables in follow-up statements. It's hardly the feature OP was describing.
Same applies to readonly instance fields.
Where does "syntax sugar" end and "true features" begin?
There are ways to do it. What matters is the user ergonomics, otherwise, by this logic, most higher-level languages would have even less of a claim to immutability, and yet somehow it's not an issue?
If there are exotic requirements - there are exotic tools for it. FWIW static readonlys are blocked from modification even through reflection and modifying their memory with unsafe is huge UB.
My immediate purposes require that I avoid depending on unique programming language/environment constructions, but it helps to learn, so thanks for levelling me up.
In .NET it’s just 'static readonly'.
Non-goals
It is not a goal to provide Java language support for declaring stable values.
Hmmm