6

Accoriding to javadoc,

public class AtomicInteger extends Number implements java.io.Serializable {

// code for class

}

But,

public abstract class Number implements java.io.Serializable {
//code for class
}

If Number class already implements java.io.Serializable then why do AtomicInteger implements it again?

Edit: Does Serializable being a marker interface makes any difference in this context?

Priyank Doshi
  • 12,895
  • 18
  • 59
  • 82

4 Answers4

4

Just to document it more clearly. Same situation with the abstract collection base classes.

Could also have been a mistake initially (that is now carried forward for consistency's sake).

Community
  • 1
  • 1
Thilo
  • 257,207
  • 101
  • 511
  • 656
2

There is no necessity as such, it is just for the sake of documentation.

Dhwaneet Bhatt
  • 601
  • 1
  • 8
  • 19
1

It is a good practice, and more for readable purpose. The same case with HttpServlet and GenericServlet. There are lot of other implementations in java sdk which follows this.

RP-
  • 5,827
  • 2
  • 27
  • 46
0

Does Serializable being a marker interface makes any difference in this context?

No difference at all. There is nothing special about a marker interface at the linguistic level.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216