Monday 5 August 2013

calling one class main method from another class main method

Let's use these two classes to demonstrate:

public class MainIsCallingMain {

public static void main(String args[])
{
System.out.println("==INSIDE THE FIRST MAIN METHOD==");
String[] test = {"first", "second", "third"};

SecondMain.main(test);
}
}

public class SecondMain {

public  static void main(String args[])
{
System.out.println("==INSIDE THE SECOND TMAIN METHOD==");

for(String a: args)
{
System.out.println("Second Class===" + a);
}
}

}



MainIsCallingMain won't compile the way it is.Need to configure SecondMain  on the classpath or compile both Class at same time.

@In eclipse please add the SecondMain  in MainIsCallingMain's class path.

No comments:

Post a Comment

Find Duplicate Characters In String using Java

package com.zia.test; import java.util.HashMap; import java.util.Map; import java.util.Set; public class findDuplicateCharacter { /**...