【发布时间】:2013-01-04 20:47:45
【问题描述】:
是否可以在java中将单个字符附加到array或string的末尾。示例:
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?
}
【问题讨论】:
-
我已经尝试过 append 方法,但我对如何使用它感到很困惑......
-
那么如何你尝试过使用 append 方法吗?您是否尝试过通过 + 进行简单的字符串连接?请注意,字符串和数组是完全不同的东西......
-
因为它们是字符串,您可以通过在此处执行
otherString + character来使用该语言的内置字符串连接机制。 -
您正在考虑使用 append 方法的
StringBuilder类。 -
显示更多研究成果。每次忘记/想了解一些基本操作/方法的时候不要在这里发问题。