Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Require a variable in an interface?

  1. #1
    Member
    Join Date
    Feb 2013
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Require a variable in an interface?

    So the Serializable interface is empty, but you get a warning if you dont add the serialVersionUID variable into the class. Is it possible to create an interface that does this same thing?


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Require a variable in an interface?

    I think that there's some behind the scenes magic with Serializable that mere mortals cannot create by simply creating a marker interface.

  3. #3
    Junior Member
    Join Date
    Feb 2013
    Location
    Germany
    Posts
    27
    Thanks
    0
    Thanked 5 Times in 5 Posts

    Default Re: Require a variable in an interface?

    if you wanna create an interface, that marks a class with exactly this warning, then just let your own interface extends the Serialzable.

    public interface MySerializable extends Serializable

    for your own warnings I am afraid that you must write your own validator(if you use eclipse for example)

    BTW the Serializable is a marker interface. It is use by the output and especially the input streams with reflection to find out which fields in an inheritance hierarchy are initialized from disc and which via optional constructors.
    the serialVersionUID there is to find out the version of a class if you deserialize an older class version object, I think

Similar Threads

  1. [SOLVED] Does RMI require separate threads
    By mds1256 in forum Threads
    Replies: 1
    Last Post: November 17th, 2012, 08:38 AM
  2. Replies: 0
    Last Post: August 31st, 2012, 03:43 AM
  3. [SOLVED] KeyListeners Require Focus...
    By snowguy13 in forum AWT / Java Swing
    Replies: 2
    Last Post: January 6th, 2012, 07:15 AM
  4. Code require for Drag and drop
    By anujbatta in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 25th, 2011, 07:54 AM
  5. Replies: 5
    Last Post: December 13th, 2009, 06:10 PM