Skip to content

stage 0: add arrays + interfaces and lists lessons - #188

Merged
Adrianamm merged 27 commits into
frcsoftware:mainfrom
zachwaffle4:stage0/interfaces-data-structures
Aug 30, 2026
Merged

stage 0: add arrays + interfaces and lists lessons#188
Adrianamm merged 27 commits into
frcsoftware:mainfrom
zachwaffle4:stage0/interfaces-data-structures

Conversation

@zachwaffle4

Copy link
Copy Markdown
Member

Description

this is two pages so it's more digestible 👍

Meta

Merge checklist:

@zachwaffle4
zachwaffle4 requested a review from a team as a code owner August 11, 2026 17:57
@github-actions github-actions Bot added Curriculum material Curriculum materials, lessons for students, etc examples infra Any infrastructure for building the website or syncing files stage0 labels Aug 11, 2026
@github-actions

Copy link
Copy Markdown

🌐 Preview URL: https://pr-188.frcsoftware.pages.dev

@zachwaffle4
zachwaffle4 force-pushed the stage0/interfaces-data-structures branch from ff6f4ce to 997d1b7 Compare August 11, 2026 18:01
@github-actions github-actions Bot removed the infra Any infrastructure for building the website or syncing files label Aug 11, 2026
@zachwaffle4
zachwaffle4 force-pushed the stage0/interfaces-data-structures branch from 997d1b7 to f8d173f Compare August 11, 2026 18:09
Comment thread src/content/docs/learning-course/stage0/interfaces-lists.mdx Outdated
Comment thread src/content/docs/learning-course/stage0/interfaces-lists.mdx
Comment thread src/content/docs/learning-course/stage0/interfaces-lists.mdx
Comment thread src/content/docs/learning-course/stage0/interfaces-lists.mdx
Comment thread src/content/docs/learning-course/stage0/interfaces-lists.mdx Outdated
Comment thread src/content/docs/learning-course/stage0/arrays.mdx Outdated
Comment thread src/content/docs/learning-course/stage0/interfaces-lists.mdx
Adrianamm
Adrianamm previously approved these changes Aug 30, 2026
…ata-structures

# Conflicts:
#	examples/stage0/snippets/src/Loops.java
#	src/content/docs/learning-course/stage0/loops.mdx
@Adrianamm
Adrianamm merged commit 8af7b38 into frcsoftware:main Aug 30, 2026
8 checks passed
In this lesson, we're going to learn about **arrays**, which let us store many values of the same type together,
and the **for-each loop**, a way to loop over those values that's often cleaner than the `for` loop you already know.

## Why Arrays?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is an array should come before why arrays

double motor4Speed = 0.5;
```

This works for four motors, but it doesn't scale.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's hard for this point to land since swerve drive example is used and those for the most part always have exactly 4 modules. There isn't any scaling to be done.

An example that shows 4 calls reading each property individually rather than looping (e.g logging) could show the benefit better

```

This creates an array of four `double`s, all initially set to `0.0`.
You can think of an array literal as a shorthand for creating an array this way and then filling in each value.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary and possibly confusing comment

## Indexing and Length

Each value in an array is called an **element**, and you access a specific element using its **index**, the element's position in the array.
Just like `String` and `List` (which we'll see in the next lesson), array indices in Java start at `0`, not `1`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Just like `String` and `List` (which we'll see in the next lesson), array indices in Java start at `0`, not `1`.
Array indices in Java start at `0`, not `1`.

<Aside type="caution" title="Array Bounds">
Every index must be between `0` and `length - 1`. Accessing
`motorSpeeds[4]`, or any index that's out of that range, will throw an
exception. This stops your program from continuing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
exception. This stops your program from continuing.
exception. This will crash your robot code.

Comment on lines +47 to +48
Here we use the `implements` keyword to tell Java that `UltrasonicSensor` and `LidarSensor` implement `DistanceSensor`.
If we said the `implements DistanceSensor` but didn't add a `getDistanceMeters()` method, the compiler would error.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Here we use the `implements` keyword to tell Java that `UltrasonicSensor` and `LidarSensor` implement `DistanceSensor`.
If we said the `implements DistanceSensor` but didn't add a `getDistanceMeters()` method, the compiler would error.
By implementing `DistanceSensor`, `UltrasonicSensor` and `LidarSensor` promise to fulfill the contract specified by `DistanceSensor` and provide a `getDistanceMeters()` method. Java will not allow you to compile if these methods are missing.

Comment on lines +49 to +50
We also use the `@Override` annotation to tell the compiler we are **overriding** that `getDistanceMeters()` method.
Overriding a method is a way to change the behavior of a method that's already defined in a parent class or interface.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mention that the annotation is optional, but allows the compiler to warn you if if detects errors within the overriding method


```

This imports `ArrayList<T>` and `List<T>` from the `java.util` package, which we'll use next.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generics shouldn't be included here

Comment thread src/content/docs/learning-course/stage0/interfaces-lists.mdx
// [robotHistoryTrackerClass]
class RobotHistoryTracker {
private Point position;
private final List<Point> history = new ArrayList<>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: I know that only ArrayList is mentioned in the docs, LinkedList would be better here. Could be an opportunity to mention there are multiple implementations of List to support different use cases. LinkedList works best here because we're only adding elements to the end, not inserting in the middle

@zachwaffle4 zachwaffle4 linked an issue Sep 3, 2026 that may be closed by this pull request
@zachwaffle4 zachwaffle4 added this to the First Publish milestone Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Curriculum material Curriculum materials, lessons for students, etc examples stage0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stage 0: Interfaces and Data Structures

5 participants