I have a value of type Object
. It could be of any type boolean, string, integer, long, etc. I want to convert that object into a string. I do use toString
method and works just as supposed to. However, sometimes the object could be String[]
or Integer[]
etc. (basically an array). The problem is when converting them to string ,I get a coded, not readable string. I used Arrays.toString
but it accepts only arrays and my value is of type Object
and I've used String.join(" ", value)
but this needs a type casting for the value to string and not all types can be cast into strings.
Is there a possible way to convert them to string no matter what the type is?
Note: I know that I can specify for each value an if statement and check the type but I don't think it's good way.