• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic