Re: Isn't an array to int primitive?
byhesed wrote:
byhesed wrote:
I know that primitive type variables cannot be converted to class
type, right?
But, how can the below code operate well?
?????????System.out.println(new int[10] instanceof Object);
The result is "true".
I am thinking that it is weird.
Isn't the anonymous array primitive type, is it?
Then, how can it be converted to class type, in this case, Object?
I think I know something incorrectly.
Please correct my wrong idea.
Sorry. I've just solved my question.
The book says that "Arrays are objects."
What book? Please answer.
The authority is the Java Language Specification (JLS). Also, GIYF.
<http://java.sun.com/docs/books/jls/third_edition/html/arrays.html>
Not every tertiary author is as good as every other. Any author who
contradicts the JLS is plain wrong. Some authors explain the concepts very
well, many do not even when they technically are correct. The latter category
includes many bloggers, and the category of incorrect information includes
many, many more bloggers.
So trust the JLS and augment with a) the official Java tutorials, b) reputable
writers like Brian Goetz, and c) seminal books such as /Effective Java/, 2nd
ed., by Joshua Bloch (mandatory reading!).
<http://java.sun.com/docs/books/effective/>
--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg