Java program shows hierarchy