Java Codes of various problems