Java

Arrays

14 lessons in this section of the Java tutorial. Work through them in order, or jump to the one you need.

  1. 1.Array Basics

    An array in Java is a fixed-size, ordered collection of elements of the same type stored in a contiguous block of memory.

  2. 2.One-Dimensional Array

    A one-dimensional array is a linear sequence of elements of the same type, accessed by a single integer index.

  3. 3.Two-Dimensional Array

    A two-dimensional array in Java is an array of arrays — each element of the outer array is itself a one-dimensional array.

  4. 4.Multidimensional Array

    A multidimensional array in Java is an array with more than two dimensions — an array of arrays of arrays, and so on.

  5. 5.Jagged Array

    A jagged array (also called a ragged array) is a multidimensional array where the inner arrays have different lengths.

  6. 6.Array Initialization

    An array is a fixed-size, ordered collection of elements of the same type stored in contiguous memory locations.

  7. 7.Array Traversal

    Array traversal is the process of visiting every element in an array to read, process, or transform it.

  8. 8.Array Sorting

    Sorting arranges array elements into a defined order.

  9. 9.Array Searching

    Searching an array means finding the position of an element that satisfies a condition.

  10. 10.Arrays Class

    The java.util.Arrays class is a utility class containing static methods for array manipulation.

  11. 11.Copying Arrays

    Copying an array in Java means creating a new array object with the same or a subset of elements from an existing array.

  12. 12.Passing Arrays to Methods

    When an array is passed to a method in Java, the method receives a copy of the reference — not a copy of the array's data.

  13. 13.Returning Arrays

    A Java method can return an array by declaring the return type with brackets and using a return statement with an array value.

  14. 14.varargs

    Varargs (variable-length arguments) allow a method to accept any number of arguments of a specified type — including zero arguments.