Link Multiple Class
Hello all expert Java programmer, i truly new to Java world.
As you all know, main is inside a class.
If i have three class, but i want to cal it from a single main. How can i do that ?
This can be easy achieve in C++ but i have no idea in C++.
You, the designer, decide which class will be your driver class - usually the one which builds the GUI and receives and delivers all input and output, dispatching messages to other classes which provide functionality which is your program's work
I rougly can understand what u mentioned here bu can u provide some concrete example.
Thanks for your help.
public class Driver
public void Driver ()
A myA = new A();
B myB = new B();
/// other construction stuff ///
public static void main( String  args )
Driver myDriver = new Driver();
///// other stuff you want to do ///
Does A and B class need main itself in its respective class ?
No. Just like C++, the only class that must have a method main is the class that is the entry point to your program.
In Java, only the class which is coded by the .java file which is the file you compile when you call javac.exe needs to have a method main.
However, it is not odd to have a method main in each class - it is a way to test the class - but those methods are not called when its class is referenced by another class which contains the entry point for your program - - - a/the constructor is called.
Thanks for your help. Problem Solved.