static blocks in interfaces?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: static blocks in interfaces?

  1. #1
    leo Guest

    static blocks in interfaces?


    Why is it not possible to have a static block in an interface to initialize
    the interface's (implicitly) public static final member variables?

  2. #2
    Paul Clapham Guest

    Re: static blocks in interfaces?


    leo <leodeegan@hotmail.com> wrote in message
    news:39170d94$1@news.devx.com...
    >
    > Why is it not possible to have a static block in an interface to

    initialize
    > the interface's (implicitly) public static final member variables?


    Perhaps you should address your question to the architects of Java instead
    of to us mere mortals. But in answer to your question, my guess is that
    interface definitions can't include executable code. Why not? Because when
    you implement an interface, all that happens is that you agree to provide
    methods with specific names and parameter lists. You don't inherit from any
    class. I'm guessing that the interface class you implemented doesn't get
    loaded by the JVM, so its static initializers would never be run.




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center