-1

I've used final keyword with class, method, fieldsbut this the first i'm seeing something like this

final Customer c=new Customer();  

could anyone help me to get what is the use of this?

1 Answers1

1

it is constant reference - you cannot change its value it can be assigned only once when being defined

due to Wikipedia

an example:

    final String string = "initial value";
    string += " some new content"; //here compiler will raise an error due to you cannot change final value
m.antkowicz
  • 13,268
  • 18
  • 37
  • can't we create clone object using c!! i'd tried but throws java.lang.CloneNotSupportedException – Venkatesh Ayyavu Sep 26 '15 at 18:33
  • it seems to be not about **final** but Customer class. Due to [CloneNotSupportedException reference](http://docs.oracle.com/javase/7/docs/api/java/lang/CloneNotSupportedException.html) - "Thrown to indicate that the clone method in class Object has been called to clone an object, but that the object's class does not implement the Cloneable interface." – m.antkowicz Sep 26 '15 at 18:56