Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Solved: Reading from an array in another class file

 
cs thiang
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 1296
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
cs thiang
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but when i put in "a ent = new a;" at c.java, won't i get a empty array again?
 
Craig Tyler
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks alot guys!! Finally got it working!!
Cheers!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic