Tsallaka zuwa abun ciki
Justice Tech School

Arrays

Arrays have a fixed size. Use length, index from 0 and Arrays.toString to print.

Example
import java.util.Arrays;
public class Main {
  public static void main(String[] args) {
    int[] a = new int[3];
    a[0] = 5;
    int[] b = {3, 1, 2};
    Arrays.sort(b);
    System.out.println(a.length + " " + Arrays.toString(a) + " " + Arrays.toString(b));
  }
}

Result

3 [5, 0, 0] [1, 2, 3]

Exercise

Array length.

a.

Quiz Test

Is an array size fixed?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.