(a)
int i = 10;
System.out.println((new Integer(i)).hashCode()); // Use wrapper class

(b)
int i = 10;
System.Console.WriteLine(i.GetHashCode()); // Conversion is implicit

Example 2: Value types. (a) in Java; (b) in C#.

Back to Article