package testcode; /** * Basic object functions that have special translations: hashcode, equals, * toString. * */ public class ObjectFunctions { private final int a; public ObjectFunctions(int a) { this.a = a; } @Override public String toString() { return Integer.toString(a); // aotoboxing not yet supported } @Override public int hashCode() { return a; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ObjectFunctions other = (ObjectFunctions) obj; return a == other.a; } public static void main(String[] args) { // 'final' should be ignored as not supported in python. final ObjectFunctions v = new ObjectFunctions(12); ObjectFunctions v2 = new ObjectFunctions(12); System.out.println(v.toString() + Boolean.toString(v.equals(v2)) + Integer.toString(v.hashCode())); // 12True12 . We avoid autoboxing - not supported // notice that in java this will print 12true12 -- LOWER CASE T. } }