Implement serializable if I already extend it?

T

timasmith

If I extend an exception (which can be serialized) do I need to
explicitly implement serializable?

public class MyException extends Exception {

static final long serialVersionUID = 1L;

public MyException(Exception exception){
super(exception);
}

}

thank

Tim
 
Z

zero

(e-mail address removed) wrote in @f14g2000cwb.googlegroups.com:
If I extend an exception (which can be serialized) do I need to
explicitly implement serializable?

public class MyException extends Exception {

static final long serialVersionUID = 1L;

public MyException(Exception exception){
super(exception);
}

}

thank

Tim

No.

The main reason for mentioning it, even though it's not really necessary,
would be to make it more obvious that you're implementing it. So it's
mostly for readability.
 
R

Roedy Green

If I extend an exception (which can be serialized) do I need to
explicitly implement serializable?

public class MyException extends Exception {

static final long serialVersionUID = 1L;

public MyException(Exception exception){
super(exception);
}

Any subclass automatically implements all the interfaces of the base
class. You can optionally provide another serialVersionUID which can
be considered the version number of the extension fields
..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top