This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
in a more general view, this does not have necessarily anything to do with arrays. More with the topic Polymorphism. When you have a polymorph variable e.g. Object variable = new Integer(42);
Then variable is of type Object and you can perform only Object methods on it (for example hashCode() or toString()); You can never do any integer things with variable. Because a variable has a fixed type that can never changed. But you can set up a second variable of type Integer, and refer this new variable to the Integer object (object as object, not as class Object!): Integer i = (Integer) variable; System.out.print(i/6);
ok, the last line requires autoboxing and won't do in java 1.4
This general issue is the base of your array question.
Hope this cleares something.
The cause why Srinivasan's code does not compile is the fact that java is CaSe sEnsItiVE.