JAVA codes will be pasted here