• 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
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

anonymous classes

 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello java ppl
I wanted to know if we can declare an anonymous class without extending "any claess" or implementing any interface .
I have tried this :
new () {};
but it won't work
if yes plz be kind enough to include the code
Regards denish.
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi denish,
u'r q did trigger of a chain of thoughts but if u analyse u'r question from the utility point of view u will see why sun has not incorporated a provision of creating anonymous class that aren't related 2 an interface or class.This is because anon classes exist 2 create objects on 'fly' 4 a small yet specific purpose. it is 4 this reason that u override various method implementations in the anon class. Without it there would be no meaning of anon classes & an inner class implementation would better serve the purpose. I hope this helps.
Regards,
Kaushik
 
denish mehta
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Kaushik
I know why java did it i was actually confirming if i am missing some thing for exam. Because for SCJP i think u never know what is enough .Thanx for the reply any way
Regards Denish.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic