×

java · level 1 · unit 2 · lesson 2

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

Put something new in a box and the old thing is gone.

A box holds one value at a time. Put a new value in and the old one is thrown away. We say you it. Write the type only once, when you first make the box.

You can copy one box into another, like String order = drink;. You can also strings with +, which sticks them end to end, so mind the spaces.

A box can even use its own value. score = score + 1; takes what is in score, adds one and puts the answer back in.

public class Main {
    public static void main(String[] args) {
        String drink = "tea";
        drink = "coffee";
        System.out.println("I would like " + drink);
        int score = 5;
        score = score + 1;
        System.out.println(score);
    }
}

When you join strings, put any spaces you need inside the quotes.