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,407
  • 17
  • 57
  • 81

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
  • 250,062
  • 96
  • 490
  • 643
2

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

Dhwaneet Bhatt
  • 601
  • 1
  • 9
  • 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,807
  • 2
  • 26
  • 43
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
  • 669,072
  • 92
  • 771
  • 1,162