Hello,
In static nested classes, do static variables still need to be marked final?
Static variables in Static Classes
Moderator: admin
-
- Posts: 13
- Joined: Fri Sep 09, 2022 5:03 pm
- Contact:
-
- Site Admin
- Posts: 10398
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: Static variables in Static Classes
No, they do not need to be marked final. There never was such a restriction on static nested classes.
Before Java 16, non-static nested classes i.e. inner classes were allowed to have a static field only if that field were final. This restriction has been removed in Java 16.
Before Java 16, non-static nested classes i.e. inner classes were allowed to have a static field only if that field were final. This restriction has been removed in Java 16.
-
- Posts: 13
- Joined: Fri Sep 09, 2022 5:03 pm
- Contact:
Re: Static variables in Static Classes
I see. So does the 1Z0-819 test reflect this change? Or should I still stick to the rule that non-static inner classes can only have a static field if it is final?
-
- Site Admin
- Posts: 10398
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: Static variables in Static Classes
This change occurred in Java 16, since 1z0-819 is based on Java 11, this change is not applicable to that exam.
Who is online
Users browsing this forum: No registered users and 6 guests