Hey Amit,
First of all Mendix Generates the java code everytime you run the app from the modeler.
In Mendix Java Actions you have comments like the following:
// BEGIN USER CODE
...your code
// END USER CODE
You should write all your custom methods in between those comments to ensure that they are save for the next deploy