Skip to content

Java Fundamentals#18

Open
Adrianamm wants to merge 3 commits into
frcsoftware:mainfrom
Adrianamm:IntroToJava
Open

Java Fundamentals#18
Adrianamm wants to merge 3 commits into
frcsoftware:mainfrom
Adrianamm:IntroToJava

Conversation

@Adrianamm
Copy link
Copy Markdown
Collaborator

Added explanations for

  • Syntax
  • Variables
  • Print Statement
  • Comments
    No exercises yet

Adrianamm added 3 commits May 7, 2026 20:50
works but has pages that aren't needed...but it works
@Adrianamm Adrianamm linked an issue May 12, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Collaborator

@EdanThomton EdanThomton left a comment

Choose a reason for hiding this comment

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

Looks good, mostly spelling mistakes and clarity rewrites.

## Variables
Variables are containers that are used to store information in a program. This could be a variable that holds the temperature or a variable that holds the speed of the motor.

The syntax of a variable is has following:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is has

small typo here
IMO "is" is the correct word here

Datatype name = value;
```
Data types refer to the type of value that our variable has. It helps tell our program more information about our variables such as what type of information it holds and how it can be used.
Data types can include numbers, characters or a string of words. Some examples of data types that are commonly used in FRC programming are:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Some examples of data types

for clarity this might be better as "Some example data types"

Data types refer to the type of value that our variable has. It helps tell our program more information about our variables such as what type of information it holds and how it can be used.
Data types can include numbers, characters or a string of words. Some examples of data types that are commonly used in FRC programming are:
* Int: integers or numbers that are positive or negative. Int only allows numbers without decimals. Example: 12
* Double: Double: numbers that are positive or negative. Unlike int, double allows numbers with or without decimals. Example: 34.1
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Double: Double:

double is repeated twice here

* Double: Double: numbers that are positive or negative. Unlike int, double allows numbers with or without decimals. Example: 34.1
* Boolean: either True or False.
* String: holds a sequence of characters. Example: “Hello World”
* Char: holds a Single character. Example: 'A'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Single

small capitalization thing

also on the topic of capitalization, are we talking about the primitive types here, or the wrapper objects? This is a bit pedantic for a beginner level course, but int and Int are technically two separate things

```
Data types refer to the type of value that our variable has. It helps tell our program more information about our variables such as what type of information it holds and how it can be used.
Data types can include numbers, characters or a string of words. Some examples of data types that are commonly used in FRC programming are:
* Int: integers or numbers that are positive or negative. Int only allows numbers without decimals. Example: 12
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

integers or numbers

small rewrite for clarity: "Integer numbers"


## Comments
When programming, we use comments to write notes that explain what the code does. This helps make the code more readable for others because if they are unsure of what your code does, they can read your comments. Comments are not run by the compiler, which also means that you can use comments to prevent code from running.
In Java, there are two types of comments. Single-line Comments and Multi-line Comments.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

some clarity things:

  • "Comments are not run by the compiler" could probably be changed to "Comments are ignored by the compiler"
  • "Multi-line" does not need to be capitalized

In Java, there are two types of comments. Single-line Comments and Multi-line Comments.

### Single-line Comments
Single-line comments are // and you add them to the front of your text or line of code. For example, the code below leaves a note of “this prints out Hello World.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For clarity, I'd probably rewrite this line to something like:

Single line comments begin with // and mark the rest of the line as being a comment. For example, the code below leave the note: "This prints out Hello World."

// This prints Hello World
System.out.print("Hello World");
```
You will also see comments placed at the end of code like the following
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For clarity pt2: I'd replace "at the end of code" with "at the end of a line"

```java
System.out.print("Hello World"); // This prints Hello World
```
Both examples accomplish the same tasks and there is no difference. If you put your comments above or next to code is up to you and what makes the most sense for your code.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For clarity pt3: in "If you put your comments above or next to code is up to you", the starting "if" should be replaced with "whether"

Both examples accomplish the same tasks and there is no difference. If you put your comments above or next to code is up to you and what makes the most sense for your code.

### Multi-line Comments
Multi-line Comments start with /* and end with */ The text or code that is in between the two will turn into comments. Multi-line Comments are commonly used when you have many lines of text or need to turn a large amount of code into a comment.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd make sure to add codeblocks `` around any in-line code (`/*`, `*/`). Also make sure to escape * as this is markdown, and *phrase* means italics

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Although in codeblocks you don't need to escape *

```
Data types refer to the type of value that our variable has. It helps tell our program more information about our variables such as what type of information it holds and how it can be used.
Data types can include numbers, characters or a string of words. Some examples of data types that are commonly used in FRC programming are:
* Int: integers or numbers that are positive or negative. Int only allows numbers without decimals. Example: 12
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Int is not a java type; there is int and there is Integer but there is no Int


The name of your variable can be whatever you want. However, it should be easy to read and make sense to others who may be reading your code.
There are also some rules with variable names. The name of the variable can not include spaces. Instead you can write variables with camel case (frontLeftDrive) and snake case (front_Left_Drive).
Variable names can not start with a number. However, they can have a number at the end of the name.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

They can have a number at any point in the identifier other than the first character (not just the end).

Java is a case-sensitive programming language! This means that uppercase and lowercase letters are treated as being two different things. For example: MotorID is different from motorID. Even though it’s spelled the same, if your variable name is MotorID then you try to reference it again but spell it as motorID, Java will see the two as different, and your code will get an error.
</Aside>

In Java, semi-colons (;) are similar to a period in a sentence. It is what tells the compiler when a line of code ends. Semi-colons are used commonly in programming and aren’t only for creating variables. We will see more examples of this later in the course.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
In Java, semi-colons (;) are similar to a period in a sentence. It is what tells the compiler when a line of code ends. Semi-colons are used commonly in programming and aren’t only for creating variables. We will see more examples of this later in the course.
In Java, semi-colons (;) are similar to a period in a sentence. It is what tells the compiler when a statement ends. Semi-colons are used commonly in programming and aren’t only for creating variables. We will see more examples of this later in the course.

I think this makes it clearer that if you do something like

int someVariable = 
  someVeryLongMethodNameThatDoesntFitOnTheOriginalLine(argument1, longArgument);

you only need one ;. Statements themselves (as well as expressions) should be covered at some point, perhaps at the end of this lesson.


## Comments
When programming, we use comments to write notes that explain what the code does. This helps make the code more readable for others because if they are unsure of what your code does, they can read your comments. Comments are not run by the compiler, which also means that you can use comments to prevent code from running.
In Java, there are two types of comments. Single-line Comments and Multi-line Comments.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
In Java, there are two types of comments. Single-line Comments and Multi-line Comments.
In Java, there are two types of comments: single-line comments and multi-line comments.

Both examples accomplish the same tasks and there is no difference. If you put your comments above or next to code is up to you and what makes the most sense for your code.

### Multi-line Comments
Multi-line Comments start with /* and end with */ The text or code that is in between the two will turn into comments. Multi-line Comments are commonly used when you have many lines of text or need to turn a large amount of code into a comment.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
Multi-line Comments start with /* and end with */ The text or code that is in between the two will turn into comments. Multi-line Comments are commonly used when you have many lines of text or need to turn a large amount of code into a comment.
Multi-line Comments start with `/*` and end with `*/` The text or code that is in between the two will turn into comments. Multi-line Comments are commonly used when you have many lines of text or need to turn a large amount of code into a comment.

next: intro-to-java/java-fundamentals
---

Learning the basics of Java is the most important step in learning FRC programming because it builds the foundation. In Java, objects are used to create motor
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This paragraph makes little sense, especially because readers at this stage probably have very little understanding of words like object and variable in this context.

In Java, there are two types of comments. Single-line Comments and Multi-line Comments.

### Single-line Comments
Single-line comments are // and you add them to the front of your text or line of code. For example, the code below leaves a note of “this prints out Hello World.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
Single-line comments are // and you add them to the front of your text or line of code. For example, the code below leaves a note of “this prints out Hello World.
Single-line comments begin with `//` and you add them to the front of your text or line of code. For example, the code below leaves a note of “This prints out Hello World" above the print statement.

## Variables
Variables are containers that are used to store information in a program. This could be a variable that holds the temperature or a variable that holds the speed of the motor.

The syntax of a variable is has following:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
The syntax of a variable is has following:
Variable declarations have the following syntax:


The syntax of a variable is has following:
```java
Datatype name = value;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Might be out of scope for this section (maybe better to specify it in the section on Objects?), but might be worth noting that any Class can be used as a datatype, not just primitives (int, double, etc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FRC Software Stage 0

4 participants