Sample coding practice in Java