Because the "final" and "static" modifiers apply to the the behaviour of the reference, not the value of the Object that reference points to. So you won't be able to do this:
but you can adjust the object's value all you like, as you do with append(). If you want the value of an object not to be changeable you must use an immutable object (in this case a String is a perfect fit).
So, keep in mind that final means you can't change what object this variable points to. However you can change the state of the object it refers to. In other words: its a reference variable. -- you can't change what the variable refers to. You can only change the state of that object
So... check out this code snippet:
does that help?
Also, this isn't an advanced question, so I'm going to move it to the intemediate forum. So please post your replies there. Thanks!
If you come from C++, this behavior can be somewhat confusing. Even though I first thought that final in Java was the same as const in C++, I eventually learned otherwise. While they are similar, and you can in fact get these same results by using const in C++, this is not quite what I expected. I guess I'm just trying to say that I understand the confusion here. I hope you are enjoying your Java endeavors.