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.


1 comment :

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training in India . Nowadays Java has tons of job opportunities on various vertical industry.