String has a concat(String) method which is used for concatenating.
Illustration
String string1 = "Java";
string1.concat("Programming");
System.out.println(string1);
So, guess what will be string1?
JavaProgramming ??
No!!
Its, still Java
Because Strings are immutable in Java
Illustration
String string1 = "Java";
string1.concat("Programming");
System.out.println(string1);
So, guess what will be string1?
JavaProgramming ??
No!!
Its, still Java
Because Strings are immutable in Java
No comments:
Post a Comment