Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. package com.tradefxl.pixelsubmitter;
  2.  
  3. public class Test {
  4.     public static void main(String[] args) {
  5.         String str = "foo";
  6.         byte[] arr = new byte[] {'f', 'o', 'o'};
  7.  
  8.         System.err.println(str.hashCode() == arrHashCode(arr));
  9.     }
  10.  
  11.     private static int arrHashCode(byte[] value) {
  12.         int h = 0;
  13.  
  14.         for (int i = 0; i < value.length; i++) {
  15.             h = 31 * h + value[i];
  16.         }
  17.  
  18.         return h;
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement