Thanks a lot j2me64...Here i solved that problem in this way:
In the MAIN method i had written:
int choice;
choice = DisplayMenu();
while (choice != -1){
System.out.println("\nI am inside while loop !\n");
}
System.out.println("\nThanks for using this program !\n");
And in the DISPLAYMENU method i had written:
public static int DisplayMenu() // User-defined method to display a menu
{
int choice;
System.out.println(" Please select how you want to deal with the system\n '1' -> Go inside of the while loop\n '-1' -> Go outside of the while loop...Program Ends !\n");
Scanner in = new Scanner(System.in);
choice=in.nextInt();
return choice;
}
And this is running exactly like the way i want too.......