String类的toString 方法,String类重写了Object的toString方法,用于返回String的字符串值
package test;
public class TestString {
public static void main(String[] args) {
String cc="hello2 "+"1s";
cc.toString();
System.out.println(cc.toString().trim());
}
}j结果:hello2 1s
本文详细解析了String类的toString方法,包括其重写原理及应用实例,通过示例代码展示了如何使用该方法并进行字符串处理。
487

被折叠的 条评论
为什么被折叠?



