Cod*_*ver 47 java string append
是否可以在java中将单个字符附加到数组或字符串的末尾
例如:
private static void /*methodName*/ () {
String character = "a"
String otherString = "helen";
//this is where i need help, i would like to make the otherString become
// helena, is there a way to do this?
}
Run Code Online (Sandbox Code Playgroud)
And*_*ler 89
1. String otherString = "helen" + character;
2. otherString += character;
Run Code Online (Sandbox Code Playgroud)
new StringBuilder().append(str.charAt(0))
.append(str.charAt(10))
.append(str.charAt(20))
.append(str.charAt(30))
.toString();
Run Code Online (Sandbox Code Playgroud)
这样你就可以获得你想要的任何字符的新字符串.
| 归档时间: |
|
| 查看次数: |
385340 次 |
| 最近记录: |