int hashCode()
描述 (Description)
hashCode()方法用于返回此Vector的哈希码值。
声明 (Declaration)
以下是java.util.Vector.hashCode()方法的声明
public int hashCode()
参数 (Parameters)
NA
返回值 (Return Value)
方法调用返回此列表的哈希码值(int)。
异常 (Exception)
NA
例子 (Example)
以下示例显示了java.util.Vector.hashCode()方法的用法。
package com.iowiki;
import java.util.Vector;
public class VectorDemo {
public static void main(String[] args) {
// create an empty Vector vec with an initial capacity of 4
Vector<Integer> vec = new Vector<Integer>(4);
// use add() method to add elements in the vector
vec.add(4);
vec.add(3);
vec.add(2);
vec.add(1);
// let us get the hashcode of the vector
System.out.println("Hash code :"+vec.hashCode());
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
Hash code :1045631