Code written in java