How do I call one class to another?,
October 30, 2008 at 6:41 AM
I read up articles here on this but none seem to have made me clear as it seems too complexed. Prefer to get a reply in the most simplest way as I'm new to java.
Here is my question. How do I call one .java to work in another .java? [code] here is an eg;
import java.util.Scanner; public class Testone { public static void main (String[] args) { Scanner scan = new Scanner(System.in); int num; System.out.println ("Enter 1 to go to Menu"); System.out.println ("Enter 2 to quit"); num = scan.nextInt(); } } [/code]
So when the user keys in 1 , how do i make a new java file that would load up to this? So lets say I create a new java file maybe naming it as public class Menu , so now how do I go about linking them up ? (take note: i do not want to use the switch method. just want to know how i can link up 2 seperate java files to work together).
Please do help me out in the most simplest java langauge.