Home > Back-end >  Do you have final int value this writing?
Do you have final int value this writing?

Time:11-23

Don't know where is wrong

CodePudding user response:

Final modify variables it is immutable, can only be assigned once.
You just started to learn, this is according to the writing is not good...

CodePudding user response:

Can go to see the final keyword

CodePudding user response:

reference 1st floor maradona1984 response:
final modify variables it is immutable, can only be assigned once.
You just started to learn, this is according to the writing is not good...

Yeah just learning, it is the teacher of the topic, let's run and correct mistakes

CodePudding user response:

Expressed in the final modify member variables constant, can only be assigned once, after the assignment value cannot be changed!
Your code line 6 of the value assignment again, so will go wrong
Besides the original poster you want to think why Java design final this thing? In the program can be used when using final modify variables,

CodePudding user response:

1, after a variable added a final, not to the assignment
2, the variables defined in the class, this is no problem, it has become a property of a class, but then this attribute assignment, this is a statement of execution, must be put in method, Java all statements must be in inside the method body

CodePudding user response:

Final int value=https://bbs.csdn.net/topics/128;//has been specified values
Value=https://bbs.csdn.net/topics/256;//in the first place, rather than in the code block, nor in the method, second, the value is the final modification and cannot be changed

CodePudding user response:

Want to run to the main function, have to write the code in the main method, after the final modification after first assignment, are not allowed to change again,

CodePudding user response:

Remember that when the final modify variables, the variables into a constant value cannot be changed

CodePudding user response:

So this code to set up, need to delete the value assignment?

CodePudding user response:

references 9 f m0_50665479 response:
to set up the code, so need to delete the value assignment?
yes, can't again to the value assignment, final modification after the value is not variable, can be regarded as a constant

CodePudding user response:

Do you want to write a main method to test ah, brother

CodePudding user response:

This is the teacher assignments, I just learned???? Don't, why
  • Related