I am using a method that returns an Object when called. That object’s type is java.util.Collections.unmodifiableSet . The collection holds only one value, that I need to access and feed to another method. The problem is that doing this:
Object o = table.getValue().toString();
returns the value surrounded in [ ] since it is a Collection. The other method needs to be called with Object type parameter, that should be only the value without the [ ]. I have got the thing working by removing the square brackets with regular expression, but would like to get the thing working by somehow casting the collection to an appropriate type.
You could use the iterator:
will return the first value of the collections iterator. (Assuming,
table.getValue()returns the collection)