IMMUTABLE STRINGS
In java, string objects are unmodifiable or unchangeable, simply called immutable.
e.g for the same is as below::
class Testimmutablestring
{
public static void main(String args[])
{
String m="SKN"; m.concat(" SCOE");//concat() method appends the string at the end
System.out.println(s);//will print SKN because strings are immutable objects
}
}
class Testimmutablestring
{
public static void main(String args[])
{
String m="SKN"; m=m.concat(" SCOE");
System.out.println(s);//will print SKN SCOE
}
}
e.g for the same is as below::
class Testimmutablestring
{
public static void main(String args[])
{
String m="SKN"; m.concat(" SCOE");//concat() method appends the string at the end
System.out.println(s);//will print SKN because strings are immutable objects
}
}
class Testimmutablestring
{
public static void main(String args[])
{
String m="SKN"; m=m.concat(" SCOE");
System.out.println(s);//will print SKN SCOE
}
}
Comments
Post a Comment