File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Does an array implements Serializable automatically ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Does an array implements Serializable automatically ?" Watch "Does an array implements Serializable automatically ?" New topic
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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Does an array implements Serializable automatically ?
 
Similar Threads
Operators Assigment!
Arrays initialization
Bug in ObjectOutputStream
Abstract class??
exceptions and type casting confusion