Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

newbie visibility question

Posted on 2002-04-05
7
Medium Priority
?
193 Views
Last Modified: 2010-03-31
Hello all
I have a class Fred.  A Fred object has a property a and a public boolean method b().
I also have a class Barney, which is very important to a lot of other classes.  Barney's main data object is an array of Fred objects:
public Fred[][] fredArray = new Fred[8][8];
Lots of other classes need to access this array of Fred objects.
One of them, class Wilma, wants to say something like:
boolean wilmaBool = fredArray[x][y].b()
What verbiage needs to be at the top of which classes to make this happen?
I mean, I probably need stuff like import or maybe package at the top of some/all of these classes, but I'm a bit lost as to what goes where.

Thanks for your help,

Edmund
0
Comment
Question by:edmund_mitchell
7 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 6922296
 You do not have to import anything. Just put all the classes in the same package and then you can access them by simply declaring them - without importing them.

  Hope it helps.
0
 
LVL 6

Accepted Solution

by:
expertmb earned 280 total points
ID: 6922431
Hi,
 You want to access that array in other classes then you have two options
 1. Make that array static and you can access like
   Barney.fredArray[x][y].b()
 2. have the Barney object and then access
   Barney barney;
   barney.fredArray[x][y].b()
 
 As mentioned by girionis if all the classes are there in  
 same package no need to import anything. if in other
 package then you have to import.
0
 
LVL 2

Expert Comment

by:vogen
ID: 6922443
expertmb is right
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Expert Comment

by:objects
ID: 6922446
What sort of a proposed answer is that???
0
 
LVL 6

Expert Comment

by:expertmb
ID: 6922517
what is this vogen?
you can post comment and dont propose somebody's comment as proposed answer.

mb...
0
 
LVL 4

Author Comment

by:edmund_mitchell
ID: 6922675
A vote of confidence in someone else's response is not an answer.
0
 
LVL 4

Author Comment

by:edmund_mitchell
ID: 6922677
Thanks
Edmund
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This video teaches viewers about errors in exception handling.
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question