| Author |
Solved: Reading from an array in another class file
|
cs thiang
Greenhorn
Joined: Jan 31, 2006
Posts: 8
|
|
 I have an array in a.java, den b.java is suppose to collect data and put inside the array in a.java. den I need c.java to read from the array to see wad b.java has entered. If i use "a ent = new a;" I would get a blank array again...so how do i read from c.java to see what b.java has put in a.java's array? Thanks in advance [ January 31, 2006: Message edited by: cs thiang ]
|
 |
Garrett Rowe
Ranch Hand
Joined: Jan 17, 2006
Posts: 1295
|
|
|
If you declare the array in a.java as static, then it will be the same when you try to access it from c.java.
|
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
|
 |
cs thiang
Greenhorn
Joined: Jan 31, 2006
Posts: 8
|
|
|
but when i put in "a ent = new a;" at c.java, won't i get a empty array again?
|
 |
Craig Tyler
Ranch Hand
Joined: Jan 15, 2006
Posts: 52
|
|
|
If the array is static, then you can access it by the class name instead of an object name. Thus, you don't need to instantiate a new object to get to the array. You would just use a.arrayName to access it.
|
 |
cs thiang
Greenhorn
Joined: Jan 31, 2006
Posts: 8
|
|
Thanks alot guys!! Finally got it working!! Cheers!
|
 |
 |
|
|
subject: Solved: Reading from an array in another class file
|
|
|