Saturday, December 18, 2010

Calling main method inside main method java

Here is the way for $subject.

import java.util.*;

public class Main {

 public static void main(String[] args) {
  System.out.println("Hi I need to call main inside main");  
  System.out.println("Do you need to exit? (y|n)");
  Scanner scanner=new Scanner(;
  String s=;
  char ans=s.charAt(0);
  case 'y':System.exit(0);break;
  case 'n':String[] argz={"A","B"};



Note: if you need to invoke a main method of another class it should be done through the name of that particular class as main is a static method.


No comments :

Post a Comment