In my main function of Helloworld.java class, I created a string or an object. Then, I created another class HelloAnotherClass.java. I want to pass my variable from Helloworld main() to main function of HelloAnotherClass.java.
package helloworld;
public class HelloAnotherClass {
public static void main(String[] args) throws IOException, ParseException {
//... for example print passed variables
}
How can I send the variables from HelloWorld main() to HelloAnotherClass main() using arguments or another structure of data and then return it againt to HelloWorld.java? Briefly, I vant to use main() function of another java class as a function in HelloWorld class.
that is the code sample I wrote
HelloWorld {
/** * @param args the command line arguments */
public static void main(String[] args) {
HelloAnotherClass.main("example");
}
public class HelloAnotherClass {
public static void main(String coming) throws IOException, ParseException {
System.out.println(coming);
}