Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   Importing classes! (http://www.programmingforums.org/showthread.php?t=15051)

zanatos Jan 27th, 2008 12:40 PM

Importing classes!
 
I am making a small program that will use the quadratic equation to solve a problem. I am suppose to make two separete classes, one to ask for input(main method) and the other to calcuate. So far I made both classes and wrote the code. However, I am having problems importing the second class and calling it! I know I have to write this import classname; but how do I call the class? so it can do its function.

Thx in advance.

Eric the Red Jan 27th, 2008 1:49 PM

Re: Importing classes!
 
If you've got 2 classes / 2 separate files. You'll be able to instantiate an instance of your calculate class (from within your other class) Done like so ->

:

Calculate calc = new Calculate();

Furthermore, if you want to call methods from that class you do

:

int theValue = 0;
theValue = calc.calculateIT();


zanatos Jan 27th, 2008 5:34 PM

Re: Importing classes!
 
Thanks alot, it works great!

Eric the Red Jan 28th, 2008 11:36 PM

Re: Importing classes!
 
Not a problem. Good luck!


All times are GMT -5. The time now is 3:37 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC