newbie visibility question

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
LVL 4
edmund_mitchellAsked:
Who is Participating?
 
expertmbConnect With a Mentor Commented:
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
 
girionisCommented:
 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
 
vogenCommented:
expertmb is right
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
objectsCommented:
What sort of a proposed answer is that???
0
 
expertmbCommented:
what is this vogen?
you can post comment and dont propose somebody's comment as proposed answer.

mb...
0
 
edmund_mitchellAuthor Commented:
A vote of confidence in someone else's response is not an answer.
0
 
edmund_mitchellAuthor Commented:
Thanks
Edmund
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.