java · level 1 · unit 1 · lesson 1
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
is a list of instructions for a computer.
Code is instructions written down for a computer. A set of instructions that does one job, like a recipe for breakfast, is called a . When you a program, the computer starts following it.
The computer follows every line exactly, from the top down. It never guesses what you meant. We will write our code in Java, a language that people and computers can both read.
In Java, your instructions always sit inside a : the lines with public class Main and main. Think of it as the box your instructions go in. Curly brackets, { and }, open and close each part.
public class Main {
public static void main(String[] args) {
System.out.println("Hello!");
}
} Press run and the computer says Hello! back to you, because the middle line is your instruction.
guess first
Spot the typo. What will the computer show?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
public class Main {
public static void main(String[] args) {
System.out.println("Happy brithday, Gran!");
}
}
your turn
Your turn. Teach the computer a dance.
Make up a dance move and type it between the quotes on line 4. Then press run and watch the steps appear in order.
output
press run to see what happens
fix it
Shoes before socks? Can you fix it?
output
press run to see what happens
- The computer runs the lines from top to bottom. Which one happens first here?
- Shoes first, then socks? Ouch. Lines 3 and 4 are in the wrong order.
- Swap lines 3 and 4 so the socks line comes first, then press run.
nailed it
you wrote and ran your first program. :D
- Code is a list of instructions for a computer.
- Your instructions go inside the frame, like a box.
- The computer does exactly what you write, top to bottom.
new words in your collection
- code
- program
- run
- frame
This lesson isn’t saved. A free account remembers every lesson you finish.