Hello World Picture


it’s homogeneous

  • Arrays can only store elements of the same data type.

integer arrays can only store integer variable, String arrays can only store String variable.


it’s immutable

  • Arrays can’t be resized.

ex) Can’t change 5 lengths to 7

  • if you want to resize length, then you need to create and initialize another Array.

it’s Object

it’s reference type, and it’s not primitive type.

This means that the array does not store the actual data directly,
and rather references the memory address where the data is stored.

an array is an object of a dynamically created class.

Java also can store primitive values or objects in arrays.
we can also create single-dimensional or multidimensional arrays in Java (same as C/C++).

Java arrays implement the Serializable and Cloneable interfaces.

Serializable interface
The Serializable interface makes an object serializable.

That is, it converts the state of an object into a stream of bytes so that it can be stored in a file or sent over the network.

  • serialization: it convert from Object data of JVM Memory to bytes
  • deserialization: Converting serialized byte data into objects that persist in the JVM.

Things to watch out for when using Java serialization in practice

  • Problem of changing class structure when deserializing
    • Throwing java.io.InvaildClassException when a class member changes and the SUID (serialVersionUID) does not match
      • Use default hash value of class if SUID is not declared
    • Sometimes even the same SUID can cause problems
  • Capacity issues
    • Serializing objects of this type, such as classes or lists within a class, can be bloated because it has meta information about all the classes it references.
    • With minimal metadata, such as JSON, it can be at least 2x and up to 10x larger for the same data than the tested format.
  • Compatibility issues
    • Only Java can handle it, which is inconvenient.

Cloneable interface

  • The superClass of every class is java.lang.Object
  • Object method, which implements the clone method to allow cloning of any of its children’s classes.
  • The ability to copy a child’s object can be accomplished by overriding the clone() method of java.lang.Obejct.
  • However, if the child class does not have cloneable functionality, a CloneNotSupportException is thrown.
  • Therefore, the target child class that is being cloned must implements cloneable. (Template patterns can be extended)

What’s included in Arrays?

Contiguous memory space

index and memory addresses