Arrays
LockedLesson 7 of 60 · DataStructures · Easy
Mastery0% of 85%
Up next: Variables and Primitive Types (~7 min) →Finish these first:Loops →Or pass the tests below to unlock it now.
1
The big idea
Arrays have fixed length and are zero-indexed; they are objects. Out-of-range access throws ArrayIndexOutOfBoundsException.
Think of it like this: Think of data structures as specialized toolboxes: a List keeps items in numbered slots (`0, 1, 2...`), a Set keeps only unique badges, and a Dictionary/Map labels each compartment with a custom name key.
Key words (tap to learn):
2
Read the lesson
Arrays have fixed length and are zero-indexed; they are objects.
int[] xs = new int[3];
int[] ys = {3, 1, 2};
Arrays.sort(ys);
Arrays.toString(ys);
int[][] grid = new int[3][4];
Out-of-range access throws ArrayIndexOutOfBoundsException.
3
Quick check
Before writing code: What should `Solution.max(new int[]{1,5,2})` return when your implementation of Arrays is working?
4
2 sample tests, 1 hiddenYour challenge
Write static int max(int[] xs) (assume non-empty).
Stuck? Get a hint (free)
More learning tools(compare languages, visual guide, related lessons)
Compare with another language
Similar to python.lists (50% overlap). Python lists are dynamic; Java arrays are fixed-size (use `ArrayList` for growth).
Visual walkthrough
A diagram, a step-by-step animation, and short captions for Arrays.
Mastery0%
Learn this first
- LoopsNot yet