LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Java Question on using your own class (https://www.linuxquestions.org/questions/programming-9/java-question-on-using-your-own-class-280523/)

k1ll3r_x 01-21-2005 10:38 AM

Java Question on using your own class
 
well we came up with a simple class, and we where trying to use it, but when trying to import
Code:

import wintersclass;
import java.io.*;
public class usingwintersclassmainprogram
{
...

it wont compile, something that worked was just call out the class inside the program
Code:

public static void main(String[] args) throws IOException
{
wintersclass testName;
testName = new wintersclass();

im wondering how can i call out the class to import at the very top

rjlee 01-21-2005 11:00 AM

You only need to import a class if it's defined in a different package (i.e. subdirectory) than the class you are using. Javac will automatically search for classes in the class path when trying to resolve symbol names.

Try removing the
Code:

import wintersclass;
line from the top of the file. If that doesn't work, please post the error message that you are getting when you compile.

darkRoom 01-22-2005 10:11 AM

Hi
Just a tip, but when you instantiate your object:

Code:

wintersclass testName; 
testName = new wintersclass();

You could just do this:

Code:

wintersclass testName = new wintersclass();


All times are GMT -5. The time now is 06:57 AM.