> For the complete documentation index, see [llms.txt](https://hanfak.gitbook.io/workspace/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hanfak.gitbook.io/workspace/languages/java/beginner/data-structures/arrays.md).

# Arrays

* static array
  * does not change size of array
  * has fixed memory, all in adjacent location to first element
* terminology
  * array: An orderd list of elements
  * element: A member of an array
  * index: The position of the element in the array.
    * Starts counting at 0, so the first element is at index 0
  * size: how many elements can fit in the array
* setting with size
* setting with data
* declaring a variable of array
* Add data
* remove data
* read data
  * one element
  * reading all elements
  * reading elements depending on their index
  * ArrayIndexOutOfBoundsException
* multi dimensional arrays
* read from multidimenisonal arrays
* adding data to mulitdimensional arrays
* Copying arrays
* searching
* finding
* slicing/sublist
* comparing arrays
* sorting arrays
* Issues at runtime
  * use arraylist
* Increasing size of arrays

## Array VS Linked list

* When to use Linked List over Arrays
  * Need constant-time insertions/deletions from the list
  * Dont konw size of List
  * Insert items in the middle of the lis
* When to use arrays of linked list
  * you need indexed/random access to elements
  * Size already fixed at initiliaztion
  * Use less memory
* ArrayList handle dynamic sizing of array

## Links

* <https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html>
* <https://self-learning-java-tutorial.blogspot.co.uk/2014/02/one-dimensional-array.html>
* <https://self-learning-java-tutorial.blogspot.co.uk/2014/02/multi-dimensional-arrays.html>
* <https://www.geeksforgeeks.org/arrays-in-java/>
* <https://www.tutorialspoint.com/java/java\\_arrays.htm>
* <https://introcs.cs.princeton.edu/java/14array/>
* <https://en.wikipedia.org/wiki/Array\\_data\\_structure>
* <https://en.wikipedia.org/wiki/Array\\_data\\_type>
* <https://completedeveloperpodcast.com/episode-78/>
