Results 1 to 6 of 6
Thread: Imports
- 09-06-2008, 10:22 PM #1
Member
- Join Date
- Sep 2008
- Posts
- 29
- Rep Power
- 0
- 09-06-2008, 10:43 PM #2
Please copy and paste the error messages here.but it dosn't work.
The import statement is a way to extend the classpath to the location of the class file. The location of the classfile should be at classpath+import-path
What is the (classinformation) you refer to? Do you have an example?
import javax.swing.JFrame;
Where javax.swing is the package and JFrame is the class.
- 09-06-2008, 10:51 PM #3
Member
- Join Date
- Sep 2008
- Posts
- 29
- Rep Power
- 0
the class info is an armory, and when i import the class i only want information about the weapons i am making the class about, so it can calculate what the attack is, how much you can sell it for, and when you attack other users how much your attack is.
so it would be...
import MyGame.Amory
then how do i use the information...
-
1) missing a semicolon at the end of the import statement.
2) where's the package information?
3) AFAIK, you import a class, not "information about a class". If you want to hide implementation details, then use interfaces.
- 09-06-2008, 11:05 PM #5
If Amory is a class, create an instance of it using new and then you can call its methods:
Amory amry = new Amory();
int value = army.getValue(); // get value
For the above import to find the class Amory, the class file would be in a folder MyGame and the classpath would end at the folder containing MyGame. Amory would be in the package: MyGame.import MyGame.Amory
If none of this makes sense, go read about packages, classpath and import statement.
- 09-07-2008, 01:32 AM #6
Senior Member
- Join Date
- Aug 2008
- Posts
- 384
- Rep Power
- 5
Similar Threads
-
cannot find imports..
By little_polarbear in forum New To JavaReplies: 4Last Post: 08-25-2008, 03:57 AM -
Imports broken in JSP; HTTP Status 500-
By Aerinai in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 06-13-2008, 10:27 PM -
How to use Static Imports
By Java Tip in forum java.langReplies: 0Last Post: 04-17-2008, 07:37 PM -
Static imports (Java 5 and above)
By Java Tip in forum Java TipReplies: 0Last Post: 12-17-2007, 10:02 AM -
Organising Imports - Eclipse
By Java Tip in forum Java TipReplies: 0Last Post: 11-15-2007, 05:15 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks