I'm new to Java, and trying to translate this code into SQL:
public class hashtest {
public static void main(String []args) {
calculateHashCode("asdf","asdf","asdf");
}
public static int calculateHashCode(String a, String b, String c) {
final int prime = 31;
int result = 1;
result = prime * result + ((a == null) ? 0 : a.hashCode());
System.out.println(result);
result = prime * result + ((b == null) ? 0 : b.hashCode());
System.out.println(result);
result = prime * result + ((c == null) ? 0 : c.hashCode());
System.out.println(result);
System.out.println(a.hashCode());
System.out.println(b.hashCode());
System.out.println(c.hashCode());
return result;
}
}
How is it that the value of the result variable flips from positive to negative in the final statement, when all hashcode values are positive?
OUTPUT
I executed this code on (https://www.tutorialspoint.com/compile_java_online.php)