Ralph Cook wrote:
Zach Shaner wrote: Lets also pretend I have a separate java file named fruit basket and I wanted to use that apple instance with the data from the .getColor()
I am having to guess at what "that apple instance with the data from the .getColor()" means. Unless getColor() returns an object that is compatible with assigning to an Apple variable, the line with getColor() will not compile.
and that retyping that code in the new class wasn't an option.
I do not know what "new class" you're referring to here.
How would I access that instance with the data stored in it from another java file?
And I don't know for sure any more what "that instance with the data stored in it" refers to either.
Thanks for your reply! I'll address each of your problems in a 1.2.3 style format.
1)I guess it would make more sense if I used getQuantity(); instead of getColor(); As I said this is an example and the actual code I'm using works perfectly fine and does compile. By that apple instance I mean Apple
apple.
2) By new class I meant a new Java File.
3) "that instance" again refers to "Apple
apple" and the data comes from the "getQuantity();"
In essense all I really want to know is how to use an instance from another java file while maintaining that information in that instance.(if this doesnt make sense ignore this part. Refer back to the example)
-Zach