若要获取列表的哈希码值,您需要使用hashCode()
CopyOnWriteArrayList类的方法。
语法如下
public int hashCode()
要使用CopyOnWriteArrayList类,您需要导入以下包
import java.util.concurrent.CopyOnWriteArrayList;
以下是hashCode()
在Java中实现CopyOnWriteArrayList类方法的示例
import java.util.concurrent.CopyOnWriteArrayList; public class Demo { public static void main(String[] args) { CopyOnWriteArrayList<Integer> arrList = new CopyOnWriteArrayList<Integer>(); arrList.add(30); arrList.add(40); arrList.add(60); arrList.add(70); arrList.add(90); arrList.add(100); arrList.add(120); System.out.println("CopyOnWriteArrayList = " + arrList); System.out.println("HashCode of the CopyOnWriteArrayList class = " + arrList.hashCode()); } }
输出结果
CopyOnWriteArrayList = [30, 40, 60, 70, 90, 100, 120] HashCode of the CopyOnWriteArrayList class = -494097927