This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
i created a class called LoadArray. In it I declare a public int array: public int myArray; I then load this array with data I read in from a parm file. a very BIG file. ------------- How can I access myArray from my other classes? I do not want to call LoadArray over and over... This would cause myArray to be loaded over and over.... I am new to java as u can see.....help would be appreciated. Thanks
forno Welcome to the Java Ranch, we hope you’ll enjoy visiting as a regular however, your name is not in keeping with our naming policy here at the ranch. Please re-register under an appropriate name as shown in the policy. Thanks again and we hope to see you around the ranch!!
forno, If you declare a static variable to hold your array, then there will only be ONE for the entire class instead of one for each instance of the class. Is that what you mean?
"JavaRanch, where the deer and the Certified play" - David O'Meara
Joined: Sep 29, 2000
Oh yeah, you would get at the array by using the classname If for example in class LoadArray: static String myArray = new String; Then you can use: LoadArray.myArray[whateverIndex]; to get at a particular element of the array, or just to get at the whole thing: LoadArray.myArray