Originally posted by Mag Yeoh:
...i still cannot print out the object value...i only print out the object address only.... can i put String[] to replace Object[]???Actually what is Object[] this mean.....another question is what is ArrayList<String> this mean???
An Object[] is an array that hold references to Objects. This means that when you add something to an array, the reference is upcast to type Object. So in order to
use something in in an Object array, you normally need to downcast the reference back to its true type (for example, (MyType)array[x]...).
Typically, arrays are created with the desired type in mind. So yes,
if your array is intended to hold Strings, then
you should probably use String[] instead of Object[].
In Collections (for example, an ArrayList), all references are
automatically upcast to type Object. Prior to the introduction of generics in Java 5, it was left to the programmer to know what was being added to a collection and ensure that it was being correctly downcast when used. But with generics, the type can be specified. For example, ArrayList<String> is an ArrayList that holds Strings. (Behind the scenes, the references are still upcast to type Object. But the generic type allows the compiler to check what's actually going in, and automaticaly insert the correct downcasting.)
If your references are printing as class names and hashCodes, this suggests that the toString() method has not been overridden.
But the question here is what
type of objects does your ObjectSet contain?