• 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

Extended JFrame, use 'super'?

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all
For consistency, if you have a class that extends JFrame do you use e.g. super.whatEver(); or just whatEver()? Personaly I like it but not sure what the general way is, if there is one.
Thanks
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a constructor, you can call the superclass constructor using super() syntax.If you don't insert the call to super() as the first line in the constructor, the compiler will insert an implicit no-argument call to the superclass constructor. It is considered good practice to always put in the super() call regardless.
For method calls, you use super.methodName() syntax.If you would omit the "super." prefix, the foobar() method would be recursively calling itself -- probably leading into an endless loop and an eventual death in a stack overflow.
- Peter
 
reply
    Bookmark Topic Watch Topic
  • New Topic