| Author |
Does an array implements Serializable automatically ?
|
Faber Siagian
Ranch Hand
Joined: Jul 08, 2008
Posts: 52
|
|
Dear ranchers, Does an array implements Serializable automatically ? For instance : The result is true, but why? AClass doesn't implement Serializable but the array does.
|
Sun Certified Programmer for the Java 2 Platform, Standard Edition 5.0 (88 %)
|
 |
Sandeep Bhandari
Ranch Hand
Joined: Apr 16, 2004
Posts: 201
|
|
Because internally Arrays are objects and the class for declaring arrays can't be modified by us and we need to have arrays serialized at times and hence the designers give Arrays the power of serialization by default. Bury that into your soul: Arrays are serializable by default.
|
SCJP 96% | SCWCD 90%| SCJP mock exams | My SCJP blog
|
 |
Milan Sutaria
Ranch Hand
Joined: Jul 10, 2008
Posts: 118
|
|
api states java.util.Arrays to be it neither mentions of serializable or not being able to modify the arrays class by extending it. But when tested it sure gives an error stating Arrays() have a private access in java.util.Arrays.
|
SCJP 6 83%
Working on SCWCD/OCPJWCD
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
Java arrays are not included in the API documentation, but they are described in the JLS. See JLS - 10.7 Array Members...
An array thus has the same public fields and methods as the following class:
Milan, the java.util.Arrays class in the API is not an array. It is a utility class containing static methods for working with arrays. (Its constructor is private, so it can't be instantiated from outside the class.)
|
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
|
 |
Milan Sutaria
Ranch Hand
Joined: Jul 10, 2008
Posts: 118
|
|
|
thanks Marc for correcting me
|
 |
 |
|
|
subject: Does an array implements Serializable automatically ?
|
|
|