Path: csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!feeder.news-service.com!news.netcologne.de!newsfeed-fusi2.netcologne.de!newsfeed.straub-nv.de!news.albasani.net!.POSTED!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: Isn't an array to int primitive? Date: Sun, 08 May 2011 07:51:56 -0400 Organization: albasani.net Lines: 41 Message-ID: References: <0e7f2c35-bdb5-4a35-b695-7a18dad4b567@f31g2000pri.googlegroups.com> <688dfa8b-c31d-4372-8210-e8417a821866@k27g2000pri.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: news.albasani.net wsm65v5UsJ9/8r33uNG/SA/Hk904tjE2fuhZPp6n6U9yHplEE1CgDXWPIZWHkBqsviohrDhEjyZ7ubbZbVRXhQ== NNTP-Posting-Date: Sun, 8 May 2011 11:51:53 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="nibgZN8oZXQoXJ5A9dKj+H4ERqjlGGImp09NEVyjge4L5jAQJ2ACA+IEFoSIf/qcz/B7k2xxzZq6sUWGeY+Q1Idgdmyhw82j1fDSzaIzPjkiQHrcGhJij51QlrCl5GJv"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 In-Reply-To: <688dfa8b-c31d-4372-8210-e8417a821866@k27g2000pri.googlegroups.com> Cancel-Lock: sha1:zh/Byf2NdkdtyJut4FfVvOG+rSA= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3804 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. 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!). -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg