This week's book giveaways are in the iOS and Features new in Java 8 forums.
We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes Solved: Reading from an array in another class file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Solved: Reading from an array in another class file" Watch "Solved: Reading from an array in another class file" New topic
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: 1296
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Solved: Reading from an array in another class file