Movatterモバイル変換


[0]ホーム

URL:


Logo
thread boostgrannybook review gridpolymorphismadvertise on coderanch
    • Post ReplyBookmark TopicWatch Topic
    • New Topic
    programming forumsJavaMobileCertificationDatabasesCachingBooksEngineeringMicro ControllersOSLanguagesParadigmsIDEsBuild ToolsFrameworksApplication ServersOpen SourceThis SiteCareersOtherPie Eliteall forums
    building better world bookadvertise on coderanchthread boostmeaningless drivelbook review grid
    this forum made possible by our volunteer staff, including ...
    Marshals:
    • Tim Cooke
    • Campbell Ritchie
    • paul wheaton
    • Ron McLeod
    • Liutauras Vilda
    Sheriffs:
      Saloon Keepers:
      • Tim Holloway
      • Mikalai Zaikin
      • Roland Mueller
      • Piet Souris
      • Carey Brown
      Bartenders:

        why an abstract class is faster than an interface ?

         
        posted 15 years ago
        • Mark post as helpful
        • send pies
          Number of slices to send:
          Optional 'thank-you' note:
        • Quote
        • Report post to moderator
        Hi Friends,
        I come across *abstract classes may be a tiny bit faster (or they may not.) * in this page [JavaRanch.]
        http://faq.javaranch.com/java/InterfaceVsAbstractClass

        I want to know the reason for why abstract classes may be a tiny bit faster ?

        Thanks.
         
        author and iconoclast
        Posts: 24207
        46
        Mac OS XEclipse IDEChrome
        posted 15 years ago
        • Likes 1
        • Mark post as helpful
        • send pies
          Number of slices to send:
          Optional 'thank-you' note:
        • Quote
        • Report post to moderator
        In Java's early days, there was a technical reason for the difference. Do you know what a"virtual table" or "vtbl" is? Basically, a simple vtbl could be used for directly inherited methods, and so the JVM just had to look at two pointers to find the code for a method inherited from an abstract class -- that's relatively fast. But since any class can implement any number of interfaces, finding the code that implements an interface method would involve following a pointer to a table of interfaces implemented by a class, then searching through the table to find a vtbl for the implementation of that interface, and then finding the method pointer in the table. That's obviously a lot more work, so calling an interface method used to be measurably slower.

        These days, JVMs are a lot smarter, and most of this sort of lookup is done during dynamic compilation, so the runtime differences are small or nonexistent.
         
        Seetharaman Venkatasamy
        Ranch Hand
        Posts: 5575
        Eclipse IDEWindows XPJava
        posted 15 years ago
        • Mark post as helpful
        • send pies
          Number of slices to send:
          Optional 'thank-you' note:
        • Quote
        • Report post to moderator
        Thank you very much Ernest for your valuable points!
         
        jQuery in Action, 3rd edition
        reply
        reply
          Bookmark TopicWatch Topic
        • New Topic
        Boost this thread!

        [8]ページ先頭

        ©2009-2025 Movatter.jp