B
Bruce Sam
Below is my simple java program:
/* **************************************** */
public class MyString {
public static void main(String[] args) {
String str1 = "BCDE";
System.out.println(str1);
String str2 = "A";
System.out.println(str2);
str2.concat(str1);
System.out.println(str2);
}
}
/* **************************************** */
I think the run result should be as:
BCDE
A
ABCDE
But in fact,it is:
BCDE
A
A
Why the method of concat() doesn't work?What I hope to do is only to
concatenate the str1 to the end of str2;
/* **************************************** */
public class MyString {
public static void main(String[] args) {
String str1 = "BCDE";
System.out.println(str1);
String str2 = "A";
System.out.println(str2);
str2.concat(str1);
System.out.println(str2);
}
}
/* **************************************** */
I think the run result should be as:
BCDE
A
ABCDE
But in fact,it is:
BCDE
A
A
Why the method of concat() doesn't work?What I hope to do is only to
concatenate the str1 to the end of str2;