Solved

newbie visibility question

Posted on 2002-04-05
7
185 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 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now