Solved

newbie visibility question

Posted on 2002-04-05
7
191 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 70 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

623 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