#Variable x Constant?

5 messages · Page 1 of 1 (latest)

hearty basin
#

So, I am starting java and fail to understand why I would use a constant over a variable. Doesn't a variable basically become a constant if I just don't change its value anywhere?

sand boneBOT
#

Hey, @hearty basin!
Please remember to /close this post once your question has been answered!

fading temple
#

Functionally, yes. If you never modify a variable it's effectively a constant. However, it's good practice to mark variables as "final" if you don't plan to change them, since it makes your code clearer for the reader.

hearty basin
#

Ah, thank you!