欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

java 生成hash值

程序员文章站 2024-03-22 17:19:28
...
/**
 * @program: javademo
 * @description: hash
 * @author: sunyuhua
 * @create: 2021-11-25 12:37
 **/
public class NewHashTest {
 public static void main(String[] args) {
  NewHashTest NewHashTest=new NewHashTest();
 System.out.println("==="+ NewHashTest.hash("sunyuhua"));
 }

 final int hash(Object k) {
  int h = 0;
  h ^= k.hashCode();
  h ^= (h >>> 20) ^ (h >>> 12);
  return h ^ (h >>> 7) ^ (h >>> 4);
 }

}