-   Programming (
-   -   how do you reload the 'main' method in Java? (

ludeKing 05-29-2004 09:03 PM

how do you reload the 'main' method in Java?
Hi all,
I have a java program that is basically a menu. the user chooses an option, which takes them to another class that does various things. The when that class is finished its stuff, I want it to return to the original class with the'main' method in it and reload it, so that the user can choose another option, or choose the option to quit.

At the moment, once the second class is finished it just quits, but Ineed it to return to the original class and restart again.



public class original {

method here that displays a menu

another method that gets the value they enter

another method that calls the appropriate class depending on what they have entered.

public static void main(String args[]) {

call the three methods above, in order.


public class number1{

do some stuff

when done, return to original class, and reload 'main' // HOW?!?

please help!

eric.r.turner 05-29-2004 10:22 PM

Well, you don't "call" a class. You call methods of a class. Your main method could be something like this:


public static void main( String[] args ) {

  number1 n1 = new number1();
  boolean done = false;
  int choice = 0;

  while ( !done ) {

      choice = getMenuChoice();

      switch ( choice ) {
        case 0 :
            done = true;
        case 1 :



All times are GMT -5. The time now is 10:33 AM.