The meaning of Java code (Object[])(Object[])arrayOfBytes[1]

ShHolmes :

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!

T.J. Crowder :

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)

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=429527&siteId=1