• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

dan's single topic exams-anonymous arrays

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In his single topic exams, Dan says that anonymous classes cannot be static. But in the following example (which is also from the same exam), the anonymous class is static and the example compiles. How ?


[ Jess added UBB [code] tags to make code easier to read, check 'em out! ]
[ August 24, 2003: Message edited by: Jessica Sant ]
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
from JLS 8.1.2


An inner class is a nested class that is not explicitly or implicitly declared static.
.
.
.
Inner classes include local, anonymous and member non-static classes


Hope it helps
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually

means

and by using 'new A(2)', you are creating object of anonymous class by calling the constructor which takes integer as parameter. Then you are keeping that object reference in a static reference.
[ August 24, 2003: Message edited by: Shabbir Asiqur ]
 
They worship nothing. They say it's because nothing is worth fighting for. Like this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic