API文档中的介绍: intern public String intern() Returns a canonical representation for the string object. A pool of strings, initially empty, is maintained privately by the class String. When the intern method is invoked, if the pool already contains a stri…
1.subString()方法的作用 subString(int beginIndex, int endIndex)方法的返回的是以beginIndex开始到 endIndex-1结束的某个调用字符串. String x = "abcdef"; x = x.substring(1,3); System.out.println(x); 输出结果: bc 2.JDK6中的subString()方法 String类实现是使用到了char数组.在JDK6里面String类有三个属性char v…
一个例子 public class TestString{ public static void main(String[] args){ String a = "a"; String b = a+"b"; String c = "ab"; String d = "a" + "b"; System.out.println(c == d); //true!!!! System.out.println(c ==…
序言 在看别人的代码时发现一个方法String.join(),因为之前没有见过所以比较好奇. 跟踪源码发现源码很给力,居然有用法示例,以下是源码: /** * Returns a new String composed of copies of the * {@code CharSequence elements} joined together with a copy of * the specified {@code delimiter}. * //这是用法示例 * <blockquote>…