How do I get seperate variable values from the object in the array for example I want to get the value of the eventName variable from etest2 I put in the array
hmm... a couple things... since your array hold Object, and you added an Event object ( subclass of Object) to the array you will need to cast it back to Event so that you can access its fields... i.e...
of course, I did no uses an array element in this example... I will leave that to you to figure out... although this should be a hint...
myArray and etest variable hold the same reference to you instantiated Event object...
Before I attempt to help you, let me see if I understood your question clearly. You created an object array to store your event objects & at some point of time (code) you wishes to access a member of the event object stored in your array.
In short, you wish to print out all the contents (or some contents) of a specific (or any) event object in your array.
By invoking the toString() method of your event class, you get the hash code of this object rather than the contents. If you wishes to get the contents that this event object contains, you've to override the toString() in your event class.
So what you did below is not exactly correct, but if you'd overrode your toString() to return all its contents, it would have printed everything about the event object.
Originally posted by Felipe Walker: String thisone = myArray.toString();
As Liam had pointed out, since you stored your event objects into an Object array, you'll need to class cast them back into the event class. Once you had done that, to access the individual public members of the event class is performed simply by the dot (.) operator.
However, it is generally bad practise to have public member variables. Instead, declare them as private and have corresponding getters & setters method for accessing them.