Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
07c418a
hi
Adrianamm Jul 26, 2026
8905c69
I forgot a space
Adrianamm Jul 26, 2026
d665631
fixed maybe
Adrianamm Jul 26, 2026
ca704d9
added suggestions
Adrianamm Jul 27, 2026
3afa8fb
added ignore
Adrianamm Jul 27, 2026
564e650
Merge branch 'main' into fruitloops2
Adrianamm Jul 27, 2026
fbef351
Removed duplicate lockfile key, reverted package upgrades
httphypixelnet Jul 27, 2026
b6a7846
Merge pull request #1 from httphypixelnet/fruitloops2
Adrianamm Jul 27, 2026
5fc09b3
fixed ignore
Adrianamm Jul 28, 2026
537dec2
added ignore correctly
Adrianamm Jul 28, 2026
bcb43f1
Merge branch 'main' into fruitloops2
Adrianamm Aug 3, 2026
2ba6756
Merge branch 'main' into fruitloops2
Adrianamm Aug 10, 2026
8eae64c
Merge branch 'main' into fruitloops2
Adrianamm Aug 11, 2026
5c19510
applied suggestions
Adrianamm Aug 11, 2026
3c3002a
Merge branch 'main' into fruitloops2
Adrianamm Aug 11, 2026
efb7579
Merge branch 'main' into fruitloops2
zachwaffle4 Aug 11, 2026
45d0aee
fix pr
zachwaffle4 Aug 11, 2026
9471f82
fix loops snippets
zachwaffle4 Aug 11, 2026
10d199f
draft arrays page
zachwaffle4 Aug 11, 2026
bd94f4d
add interfaces and lists lesson
zachwaffle4 Aug 11, 2026
f8d173f
fix loops
zachwaffle4 Aug 11, 2026
b32cee7
Merge branch 'main' into stage0/interfaces-data-structures
Adrianamm Aug 15, 2026
df7b821
Merge branch 'main' into stage0/interfaces-data-structures
Adrianamm Aug 21, 2026
d82264b
review comments
zachwaffle4 Aug 21, 2026
cd73af1
Merge remote-tracking branch 'upstream/main' into stage0/interfaces-d…
zachwaffle4 Aug 28, 2026
1a6db9d
address review comments !!
zachwaffle4 Aug 28, 2026
bd516df
Merge remote-tracking branch 'upstream/main' into stage0/interfaces-d…
zachwaffle4 Aug 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions examples/stage0/snippets/src/Arrays.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright 2026 FRCSoftware
*
* SPDX-License-Identifier: BSD-3-Clause
*/

void main() {
// [motorSpeedsLiteral]
double[] motorSpeeds = {0.5, 0.5, 0.5, 0.5};
// [/motorSpeedsLiteral]

// [motorSpeedsEmpty]
double[] emptyMotorSpeeds = new double[4];
// [/motorSpeedsEmpty]

// [setSpeed]
motorSpeeds[0] = 0.7;
System.out.println(motorSpeeds[0]); // 0.7
// [/setSpeed]

// [speedsLength]
System.out.println(motorSpeeds.length); // 4
// [/speedsLength]

// [pathArray]
Point[] path = {
new Point(0, 0),
new Point(1, 2),
new Point(3, 3),
};
// [/pathArray]

// [pathArrayEmpty]
Point[] emptyPath = new Point[3];
// [/pathArrayEmpty]

try {
// [pathArrayNull]
emptyPath[0].norm(); // error: emptyPath[0] is null
// [/pathArrayNull]
} catch (NullPointerException e) {
// for demo purposes we don't care about the exception'
}

// [indexLoopSpeeds]
double total = 0;
for (int i = 0; i < motorSpeeds.length; i++) {
total += motorSpeeds[i];
}
System.out.println(total); // 2.2
// [/indexLoopSpeeds]

// [forEachPath]
for (Point waypoint : path) {
System.out.println(waypoint.getX() + ", " + waypoint.getY());
}
// [/forEachPath]

// [pathLength]
double pathLength = 0;
for (int i = 1; i < path.length; i++) {
Point segment = path[i].minus(path[i - 1]);
pathLength += segment.norm();
}
System.out.println(pathLength); // 4.47213595499958
// [/pathLength]
}
8 changes: 2 additions & 6 deletions examples/stage0/snippets/src/Loops.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void main() {

// [ForExample2]
for (int i = 0; i < 6; i++) {
System.out.println("Hi!");
System.out.println("Hi!");
}
//[/ForExample2]

Expand All @@ -63,8 +63,4 @@ void main() {
System.out.println(i); // prints 0, 1, 2, 3, 4
}
// [/forExample]




}
}
11 changes: 11 additions & 0 deletions examples/stage0/snippets/src/interfaces-lists/DistanceSensor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright 2026 FRCSoftware
*
* SPDX-License-Identifier: BSD-3-Clause
*/

// [distanceSensorInterface]
interface DistanceSensor {
double getDistanceMeters();
}
// [/distanceSensorInterface]
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright 2026 FRCSoftware
*
* SPDX-License-Identifier: BSD-3-Clause
*/

// [importList]
import java.util.ArrayList;
import java.util.List;
// [/importList]

// [isTooClose]
boolean isTooClose(DistanceSensor sensor) {
return sensor.getDistanceMeters() < 1.0;
}
// [/isTooClose]

// [genericLast]
<T> T last(T[] items) {
return items[items.length - 1];
}
// [/genericLast]

void main() {
// [distanceSensorCall]
DistanceSensor ultrasonic = new UltrasonicSensor();
DistanceSensor lidar = new LidarSensor();
System.out.println(isTooClose(ultrasonic)); // false
System.out.println(isTooClose(lidar)); // false
// [/distanceSensorCall]

// [genericLastCall]
Point[] path = {new Point(0, 0), new Point(1, 2), new Point(3, 3)};
DistanceSensor[] sensors = {ultrasonic, lidar};

System.out.println(last(path).getX()); // 3.0
System.out.println(last(sensors).getClass()); // class LidarSensor
// [/genericLastCall]

// [pairCall]
Pair<String, Integer> pair = new Pair<>("foo", 42);
String foo = pair.getFirst();
Pair<Point, Point> pointPair = new Pair<>(new Point(0, 0), new Point(1, 2));
Point secondPoint = pointPair.getSecond();
// [/pairCall]

// [historyList]
List<Point> waypoints = new ArrayList<>();
// [/historyList]

// [historyAdd]
waypoints.add(new Point(0, 0));
waypoints.add(new Point(1, 2));
System.out.println(waypoints.size()); // 2
// [/historyAdd]

// [forEachHistory]
RobotHistoryTracker tracker = new RobotHistoryTracker(Point.ORIGIN);
tracker.move(new Point(3, 0));
tracker.move(new Point(0, 4));

for (Point visited : tracker.getHistory()) {
System.out.println(visited.getX() + ", " + visited.getY());
}
// [/forEachHistory]
}
15 changes: 15 additions & 0 deletions examples/stage0/snippets/src/interfaces-lists/LidarSensor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright 2026 FRCSoftware
*
* SPDX-License-Identifier: BSD-3-Clause
*/

// [lidarSensorClass]
class LidarSensor implements DistanceSensor {
@Override
public double getDistanceMeters() {
// In real life, this would actually interact with hardware
return 1.2;
}
}
// [/lidarSensorClass]
26 changes: 26 additions & 0 deletions examples/stage0/snippets/src/interfaces-lists/Pair.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2026 FRCSoftware
*
* SPDX-License-Identifier: BSD-3-Clause
*/


// [pairClass]
public class Pair<A, B> {
private final A first;
private final B second;

Pair(A first, B second) {
this.first = first;
this.second = second;
}

public A getFirst() {
return first;
}

public B getSecond() {
return second;
}
}
// [/pairClass]
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2026 FRCSoftware
*
* SPDX-License-Identifier: BSD-3-Clause
*/

import java.util.ArrayList;
import java.util.List;

// [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


public RobotHistoryTracker(Point startPosition) {
this.position = startPosition;
this.history.add(startPosition);
}

public void move(Point delta) {
this.position = this.position.plus(delta);
this.history.add(this.position);
}

public Point getPosition() {
return this.position;
}

public List<Point> getHistory() {
return this.history;
}
}
// [/robotHistoryTrackerClass]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright 2026 FRCSoftware
*
* SPDX-License-Identifier: BSD-3-Clause
*/

// [ultrasonicSensorClass]
class UltrasonicSensor implements DistanceSensor {
@Override
public double getDistanceMeters() {
// In real life, this would actually interact with hardware
return 1.5;
}
}
// [/ultrasonicSensorClass]
Binary file added public/learning-course/stage0/loops/ForLoop.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/config/sidebarConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ export const sidebarSections: Record<string, SidebarSection[]> = {
// label: 'Methods',
// slug: 'learning-course/stage0/methods',
// },
{
label: 'Arrays and For-Each Loops',
slug: 'learning-course/stage0/arrays',
},
{
label: 'Interfaces, Generics, and Lists',
slug: 'learning-course/stage0/interfaces-lists',
},
],
},
{
Expand Down
Loading