java万能字符串截取
时间: 2023-12-22 12:28:58 浏览: 162
字符串 截取
```java
String str = "Hello, World!";
String subString = str.substring(7, 12);
System.out.println(subString); // 输出:World
```
```java
StringBuffer buffer = new StringBuffer();
buffer.append("Hello");
buffer.append("World");
String result = buffer.toString();
System.out.println(result); // 输出:HelloWorld
```
```java
StringBuilder builder = new StringBuilder();
builder.append("Hello");
builder.append("World");
String result = builder.toString();
System.out.println(result); // 输出:HelloWorld
```
阅读全文