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 2 of 2

Thread: serialVersionUID and abstract stuff

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default serialVersionUID and abstract stuff

    /*
     * Task 2
     *
     * 1. Implement all the missing methods in MyStack.
     * 2. Implement the MyQueue class using the provided Queue interface.
     *    2a. You should use two stacks (MyStack) to implement the MyQueue methods.
     */
    package task02;
     
    interface Stack
    {
        public abstract int pop();
        public abstract void push(int i);
        public abstract boolean isEmpty();
    }
     
    class MyStack implements Stack 
    {
        public MyStack() 
        {
        }
     
        public int pop()
        {
        }
     
        public void push(int i) 
        {
        }
     
        protected class StackException extends RuntimeException 
        {
            private static final long serialVersionUID = 1L;
     
            public StackException(String s) 
           {
                super(s);
            }
        }
     
        public boolean isEmpty() 
        {
        }
     
        public String toString() 
        {
        }
     
    }
     
    interface Queue 
    {
        public abstract void enqueue(int i);
        public abstract int dequeue();
        public abstract boolean isEmpty();
    }

    Ok so the first question i have is about the

    public abstract int pop();
    public abstract void push(int i);
    public abstract boolean isEmpty();

    Basically i dont understand what the abstract means. I've learnt about abstract classes before and why they should be abstract, but havnt dealt with abstracts in declaring variables.


    And the 2nd but main question i have is about the private static final long serialVersionUID = 1L thing. Ive googled that and some of the explanations i got were so full of technical terms i had no idea what they were saying. Please enlighten me =]


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,136
    Thanks
    48
    Thanked 2,156 Times in 2,129 Posts

    Default Re: serialVersionUID and abstract stuff

    havnt dealt with abstracts in declaring variables.
    The examples you show are for abstract methods not variables.
    Do you have any examples with abstract variables?

    The serialVersionUID is to allow the readObject method to detect if a serialized class is the correct version for the class object it is trying to generate.

Similar Threads

  1. strong stuff
    By DarkRoast in forum Member Introductions
    Replies: 1
    Last Post: December 27th, 2010, 09:02 PM
  2. abstract class
    By robinglow in forum AWT / Java Swing
    Replies: 2
    Last Post: August 20th, 2010, 01:36 AM
  3. Can't get it to save stuff with JFileChooser
    By javapenguin in forum What's Wrong With My Code?
    Replies: 35
    Last Post: August 11th, 2010, 04:13 AM
  4. Noob, Helloworld stuff not working? Help?
    By Bdavis93 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: July 7th, 2010, 08:29 PM
  5. VB can do stuff Java can`t ??
    By JFujy in forum Java Theory & Questions
    Replies: 2
    Last Post: September 22nd, 2009, 10:25 AM