1.concat()方法,当参数为两字符串时,可实现字符串的连接: package cn.nxl123.www; public class Test { public static void main(String[] args) { String string=new String("abcdef"),tString=new String("123"); System.out.println("连接两个字符串:"); System.out.pr…
首先来看一下String中hashCode方法的实现源码 public int hashCode() { int h = hash; if (h == 0 && value.length > 0) { char val[] = value; for (int i = 0; i < value.length; i++) { h = 31 * h + val[i]; } hash = h; } return h; } 在String类中有个私有实例字段hash表示该串的哈希值,在第…