Home > Back-end >  Li gang, Java, crazy about final this paragraph have contradiction?
Li gang, Java, crazy about final this paragraph have contradiction?

Time:09-16

Why look inconsistent? What for?


CodePudding user response:

CodePudding user response:

No problem, you initialize no assignment, direct use of complains

CodePudding user response:

Please see the screenshot of the first floor

CodePudding user response:

refer to the second floor from the underlying program apes looked response:
no problem, you didn't initialization assignment, direct use of complains

See the screenshot, the first floor,,,

CodePudding user response:

The
reference 3 floor Fang Zihan response:
please see the screenshot of the first floor


Article write very clear in the static initialization blocks, in the initialization block and structural method to the final variable initialization,

{} is the initialization code block age there is no assignment, the first line print complains, assignment, sentence 3 print is not an error

CodePudding user response:

Variable to initialization assignment before to call, otherwise it complains
And compiler in the same block of code from bottom to top, printing code will compile your first line of the first, and then during the compilation of the assignment, but you in the first row has been an error

CodePudding user response:

In front of that did not indicate that must be a member of the final modification

CodePudding user response:

No default value, final variables must explicitly one-time assignment, otherwise an error, as 7th floor says, that the content of the circle, it should be said is a ordinary member fields, ordinary member fields will have a default value,

CodePudding user response:

Attention to transition, in front of your circle part refers to the member variable assignment, if no assignment will have default values

CodePudding user response:

Initialization code block is class instantiation phase, and the class member variables at the same time, the initial values of the age has not been assigned,

CodePudding user response:

Refueling believe in yourself

CodePudding user response:

Should be such,