How to write a program in Java?