I have run into some piece of code and I cannot find the meaning of this particular part:
Object[] arrayOfObject = (Object[])(Object[])localObjectInputStream.readObject();
Help[] arrayOfHelp = (Help[])(Help[])arrayOfObject[0];
The question concernes (Object[])
on the first line and (Help[])
repeated twice. It looks very much like casting but then why double casting into the same type?
Your help is very much appreciated!
There is no point of doing so. Makes no extra difference but just kills the readability and causes confusion.
There's no good reason to apply the same cast twice, it's simply an error*/quirk of the original author.
There are very few places where a double-cast even with different types is meaningful. But with the same type, no, no point to that at all.
* (a fairly harmless one, though it's not pretty)
I assume this is just a "bad" (in meaning of style and unnecessary) programming.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With