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

Abstract Static method!

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why is an abstract static method illegal?
Overriding a static method with a static method is llegal.
Why can't i declare a static abstract method??
Can someone help me?
Thanks =)
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First - overriding a static method isn't illegal, it's impossible. I.e. it's not the compiler will complain if you try to do it; rather it will interpret your attempt as something else - hiding rather than overriding. It won't throw an error, but it also won't give you any dynamic run-time lookup of methods (which is the principal difference between overriding and hiding.
Now as for the abstract part. An abstract method must be overridden in order to have a non-abstract class - i.e., in order to have a class that does anything. Since an abstract method must be overridden, and a static method can't be overridden, there's no way these two modifiers can go together.
 
I once met a man from Nantucket. He had a tiny ad
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic