public class StringTest {
public static void stringReplace(String text) {
text = text.replace('j', 'i');
}
public static void bufferReplace(StringBuffer text) {
text.append("C");
text = new StringBuffer("Hello");
text.append("World!");
}
public static void main(String[] args) {
String textString = new String("java");
textString.replace('j', 'i');
StringBuffer textBuffer = new StringBuffer("java");
stringReplace(textString);
bufferReplace(textBuffer);
System.out.println(textString + textBuffer); // javajavaC
}
}
String面试题1
最新推荐文章于 2022-11-07 22:11:41 发布