Beside objects and primitives, Java has a special type of collection storage structure called arrays. Once created, arrays cannot be grown or shrunk without copying data and creating another array to hold the result. Array elements are always homogeneous in type. Array elements are like places that you can mutate to hold new values. Unlike collections such as list and vector, arrays can contain primitive elements, which make them a very fast storage mechanism without Garbage Collection (GC) overhead.
Arrays often form a basis for mutable data structures. For example, Java's java.lang.ArrayList
implementation uses arrays internally. In Clojure, arrays can be used for fast numeric storage and processing, efficient algorithms, and so on. Unlike collections, arrays can have one or more dimensions. So, you could lay out data in an array such as a matrix or cube. Let us see Clojure's support for arrays:
Description |
Example |
Notes |
---|---|---|
Create array |
|
Array of type (boxed... |