I have an example in which the String variable is declared static . The String variable is itself immutable , then how can we declare it as static . My class compiles successfully. CAn anyone explain ?
The keyword static has nothing to do with something being immutable or constant in any way.
If you make a variable static, then there will be only one instance of that variable that's shared among all instances of the class in which the variable exists. See Understanding Instance and Class Members in Sun's Java tutorial.
When a class is immutable, it means that the state of an instance of that class can't be changed after it has been created and initialised.