What is immutable class? how to make a Class explicitly
"Immutable"?Wap to make a class explicitly immutable.
Answer Posted / rv.nandakishore
I think u know... String is not a data type.. it is a
class...right..
By default the String class is a immutable class. That means
once we instantiate the object or assigning the value to
String is immutable. Once we can assign / instantiate the
String class we can't change in the future....
class StringDemo
{
public static void main(String[] args)
{
String s1="Nanda";
String s2="Kishore";
String s3=new String("Nanda Kishore");
System.out.println(s1);
System.out.println(s2);
System.out.println(s3);
}
}
U try any changes anything and print s1,s2 & s3.... If
changes then it is not immutable. If not it is immutable.
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
How do you join strings in java?
Can an integer be a string?
What is the different between get and post?
Why vector is used in java?
What are jee technologies?
What is stack explain?
Explain about java sdk?
What is vector capacity in java?
What is string manipulation?
What is package private scope in java?
Can we convert integer to string in java?
How objects are stored in java?
what is difference between equals and ==?
What is the difference between a method and a function in alice?
What is meant by class?