Add a Java example for comparison