Home Tutorialhelp Comment How do I call one class to another?

 
 

Comment

Silan
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.

Thank you in advance.
View All Comments
Advertisement
Related Tutorial and Articles
Programming Questions

Question-Answer Guidelines
 

Java Beginners

how do i solve this question?
 

Java Beginners

i need to answer this Question but i can't do it probably
 

Java Beginners

PureStack question---i dont know how to do this
 

Java Beginners

PureStack question---i dont know how to do this
 

PHP Questions

How do you call a constructor for a parent class?
 

Java Beginners

Clarify my last question's answer - Java Beginners
 

Java Beginners

i cNT GET ANSWER FOR THIS QUESTION
 

JSP Servlet Questions

Please , can any one answer this Question?
 

Java Beginners

call frame again - Java Beginners
 

Ajax Questions

share your answer to this question
 

JSP Servlet Questions

hi,i'am new to Jsp.Can some one please let me know an answer for this question?
 

Java Beginners

How do I decompile Java class files?
 

Web Hosting Tutorial

How do I track how many hits my website gets
 

Java Beginners

How to call the run method from another class?
 

JSP Servlet Questions

how call ireports in jsp
 

Java Server Faces Questions

HOW TO I CHANGE THE SWITCH TO IF ELSE OR DO WHILE OR WHILE DO FOR THIS CODING
 

Java Server Faces Questions

HOW TO I CHANGE THE SWITCH TO IF ELSE OR DO WHILE OR WHILE DO FOR THIS CODING
 

Java Server Faces Questions

HOW TO I CHANGE THE SWITCH TO IF ELSE OR DO WHILE OR WHILE DO FOR THIS CODING
 

Java Server Faces Questions

HOW TO I CHANGE THE SWITCH TO IF ELSE OR DO WHILE OR WHILE DO FOR THIS CODING
 

Java Beginners

javascript call action class method instruts
 

Java Interview Questions

java interview question and answer - Java Interview Questions
 

Java Beginners

to know my answer
 

Interview Questions

Core Java Interview Question Page 3
 

General

Java Interview Questions - Page 5
 

JavaScript Questions

How can I do it? .click();
 

Programming Tutorials

Core Java Interview Question, Interview Question
 

Swing AWT

how to open one Jframe from main method call
 

Programming Tutorials

Core Java Interview Question, Interview Question
 

Hibernate Questions

one-to-one bidirectional association between an abstract class and a persistent class
 

Java Beginners

question
 

PHP Questions

call a constructor
 

Interview Questions

Core Java Interview Question Page 8
 

Java Beginners

how do i solve this problem?
 

Interview Questions

Core Java Interview Question Page 1
 

Programming Tutorials

Core Java Interview Question, Interview Question
 

Mobile Applications Questions

how do i make a phone call from my app without quitting my application
 

Programming Tutorials

Articles - Articles Submission Guidelines
 

Java Beginners

how to pass a string from one class to another
 

Programming Tutorials

Core Java Interview Question, Interview Question
 

Security Questions

Call Https Url
 

JSP Servlet Questions

how to call a java class in jsp - JSP-Servlet
 

JSP Servlet Questions

how to call a java class in jsp - JSP-Servlet
 

Programming Tutorials

Core Java Interview Question, Interview Question
 

Java Beginners

Java experts.Please answer this question - Java Beginners
 

Programming Questions

Question Answer
 

Programming Tutorials

Core Java Interview Question, Interview Question
 

Java Beginners

pls answer these question
 

HTML Questions

how to do two database tables in one page?
 

Java Beginners

How do I write a program to manage an employee's business and personal contacts?
 

JavaScript Questions

how do i apply the javascript validation functions to the iframe content?
 

JavaScript Questions

how do i apply the javascript validation functions to the iframe content?
 

JavaScript Questions

i have a problem to do this question...pls help me..
 

XML Tutorials

XML Interviews Question page19
 

Java Beginners

How do I do this program? I'm new to Java programming...
 

Java Beginners

How do I generate random number?
 

Java Beginners

please answer me
 

Programming Tutorials

Core Java Interview Question, Interview Question
 

Java Beginners

how to use string of one class into another Class
 

Java Server Faces Questions

How to call business deleget class(EJB) from JSF Page? - Java Server Faces Questions
 

Java Beginners

J2ME question
 

Programming Tutorials

Core Java Interview Question, Interview Question
 

Java-Tutorials

Java Interview Questions - Page 11
 

Java Beginners

question
 

Hibernate Questions

question
 

Java Interview Questions

My Base Class is Changing every time in my code. How I can overcome this?
 

Java Beginners

question
 

Programming Tutorials

VoIP Call
 

Programming Tutorials

Core Java Interview Question, Interview Question
 

Programming Tutorials

Core Java Interview Question, Interview Question
 

Java Beginners

question
 

Java Beginners

inheritance....please help me friends...!!!... this is important project that i have to do it..
 

Swing AWT

how to call a frame having threading concept
 

Programming Tutorials

Core Java Interview Question, Interview Question
 

JSP Servlet Questions

send answer
 

Java Beginners

question
 

Java Interview Questions

How I call the function union from the main - Java Interview Questions
 

Programming Tutorials

Core Java Interview Question, Interview Question
 

Java Beginners

question
 

Java Beginners

how the answer is 13 can anyone explain plz
 

SQL Question

How do I upgrade mysql?
 

Java Interview Questions

How I Choose a folder - Java Interview Questions
 

Java Beginners

java.please answer this...
 

Programming Tutorials

Core Java Interview Question, Interview Question
 

Java Interview Questions

call a function - Java Interview Questions
 

JavaMail Questions

how to do this - JavaMail
 

JSP Servlet Questions

how i do url encoding process - JSP-Servlet
 

Java Beginners

I am new to programming and I am not sure what to do next? Any ideas?
 

Java Beginners

How do I sort by mutiple columns that are in ArrayList using some comparable class
 

Programming Tutorials

Core Java Interview Question, Interview Question
 

Programming Tutorials

Core Java Interview Question, Interview Question
 

Java Beginners

how i want to create a coding by this question?
 

Interview Questions

Difficult Interview Questions Page -8
 

Programming Tutorials

Core Java Interview Question, Interview Question
 

Java Beginners

what should i do next?? - Java Beginners
 

JSP Servlet Questions

Call dll from java - JSP-Servlet
 

Ajax Questions

my answer
 

Programming Tutorials

Core Java Interview Question, Interview Question
 

Flex Questions

Data call in flex
 

Java Beginners

please i want someone to answer me pleeeeeeeeeeeeease...
 

Advertisements Advertisements
 

 

 

DMCA.com