Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-07-2008, 12:22 AM
Member
 
Join Date: Sep 2008
Posts: 29
whosadork is on a distinguished road
Imports
How do i import information from one class to another, wouldn't this be it>>>


import java.(classname).(classinformation)


but it dosn't work.

PS. I have eclypse
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-07-2008, 12:43 AM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,223
Norm is on a distinguished road
Quote:
but it dosn't work.
Please copy and paste the error messages here.

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.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 09-07-2008, 12:51 AM
Member
 
Join Date: Sep 2008
Posts: 29
whosadork is on a distinguished road
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...
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 09-07-2008, 01:02 AM
Fubarable's Avatar
Senior Member
 
Join Date: Jun 2008
Posts: 876
Fubarable is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 09-07-2008, 01:05 AM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,223
Norm is on a distinguished road
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

Quote:
import MyGame.Amory
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.
If none of this makes sense, go read about packages, classpath and import statement.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 09-07-2008, 03:32 AM
Senior Member
 
Join Date: Aug 2008
Posts: 178
Supamagier is on a distinguished road
in Mygame.Amory, Mygame would be the name of the map Amory.class is in, and Amory should have "package Mygame;" at it's first line.
__________________
check out
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
, 100% made by me.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot find imports.. little_polarbear New To Java 4 08-25-2008 05:57 AM
Imports broken in JSP; HTTP Status 500- Aerinai JavaServer Pages (JSP) and JSTL 0 06-14-2008 12:27 AM
How to use Static Imports Java Tip java.lang 0 04-17-2008 09:37 PM
Static imports (Java 5 and above) Java Tip Java Tips 0 12-17-2007 12:02 PM
Organising Imports - Eclipse Java Tip Java Tips 0 11-15-2007 07:15 PM


All times are GMT +3. The time now is 01:51 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org