can we call main method from another main method

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mahi543
    New Member
    • Aug 2007
    • 5

    #1

    can we call main method from another main method

    how can we call one class main method from another class main method?
    i tried but i got an idea for method we can call one method from another method
  • madhoriya22
    Contributor
    • Jul 2007
    • 251

    #2
    Originally posted by mahi543
    how can we call one class main method from another class main method?
    Hi,
    Plz make urself more clear. Why do you need that?
    i tried but i got an idea for method we can call one method from another method
    What do you mean by that line?

    Comment

    • misaw
      New Member
      • Aug 2007
      • 17

      #3
      Originally posted by mahi543
      how can we call one class main method from another class main method?
      i tried but i got an idea for method we can call one method from another method
      Try this ...
      [code=java]
      ClassB {
      public static void main(String[] args) {
      System.out.prin tln("ClassB main() Called");
      }
      }

      ClassA {
      public static void main(String[] args) {
      System.out.prin tln("ClassA main() Called");
      ClassB.main(arg s);
      }
      }
      [/code]

      ouput
      ClassA main() Called
      ClassB main() Called

      static methods are called without instantiating the object of class containing the method.

      Comment

      Working...