As Darryl already mentioned,
objects cannot be final;
variables can be.
You have to be aware of the distinction between objects and variables; they're not the same thing. A variable* is a reference (i.e., a pointer) to an object. Making a variable final means that you can't change the variable, in other words, you can't make the variable refer to another object. It doesn't mean that you cannot change the state of the object that the variable refers to.
To have an immutable object, the class that the object was made from has to be designed to be immutable. Some classes in Java's standard library are immutable, and some aren't. For example, class
String is immutable; once a String object is initialized, its content cannot be modified (and it doesn't matter if your variable that refers to the String is final or not). Class Date is mutable; you can change its contents (even if the variable that refers to it is final).
To make a class immutable, you'll have do a few things: make all member variables final, do not add any methods to the class that can change the state of the object, and make the class itself final so that subclasses can't make it mutable.
You have to be careful, because subtle things can go wrong. If you have any member variables that are of a mutable type,
you should be careful that you don't let them leak out, so that outside code might indirectly change the state of the object. Here's an example with two bugs:
There are two places where this class has leaks; through the constructor, and through the getDate() method:
To fix these, you'll have to make copies of the Date object in the constructor and the getter:
* of a non-primitive type