Stupid question, I'm sure: For an assignment I need to create a program that uses methods and constructors in several other classes... the classes were in a file that I unpacked and put in the same directory as the one I'm writing is in. What do I need to do so that I can call other methods/constructors from those classes and get my program to compile without telling me it can't find them??

Instantiate the class then call the method you need

If they aren't part of the same package then lets say you have a class called OtherClass in a package called other. Then you would need to add the following statement to the top of the class you wanted to use OtherClass from:

import other.OtherClass;

Then you would be able to do something like

//in some method:
OtherClass object = new OtherClass();
System.out.println(object.toString());

You'll also face problems importing those classes if they were compiled into packages and you have unpacked them into a different directory structure.

edit: Just to elaborate a bit, in the example BJSC posted above, the compiler would expect "OtherClass" to be found in a directory named "other".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.