Java 中操作字符串都有哪些类?它们之间有什么区别?
What classes are used to manipulate strings in Java, and how do they differ?
题目类型: 技术面试题
这是一道技术面试题,常见于澳洲IT公司面试中。
难度: easy
分类: Java
标签: String, StringBuffer, StringBuilder
参考答案摘要
答案 String :字符串常量,创建之后不可变(immutable)。String 类被 final 修饰,不可被继承。 StringBuffer :字符串变量(mutable),线程安全(方法通常带有 synchronized)。 StringBuilder :字符串变量(mutable),线程不安全,但性能通常比 StringBuffer 更高。
本题提供 STAR 原则详细解答和技术解析,登录匠人学院学习中心即可查看完整答案。