Different programs in language - Java