Skip to the content.

Chapter 4 - Line Editing

Back to outline

Authors pro-tip:
Listen to this song while working through the exercises

Duplicate line Macctrl+d

Open Chapter4.java, move your cursor to line 6 (try and use a shortcut for this), and press Mac + d.

Yank Mac + backspace

Press Mac + backspace repeatedly to delete the lines.

Moving lines with and without constraints Mac + shift + / vs. Macshift + + /

While in Chapter4.java, the System.out.println function calls are switched around. Place your cursor on one of the System.out.println lines, hold down Mac + shift and press or Mac to move that line. Do the same for the other line.

You will see the methods aren’t in the desired order yet, so place your cursor on _2_snarf’s method signature. This time hold down Macshift + and press or to move the entire method.

Start new line Macshift + enter

In Chapter4.java, jump to 20:20 (using Mac + l). From this position we want to start implementing the body of the method. Typically, one would do this by pressing end, and then enter. But you can do this in one go by pressing Macshift + enter, so let’s do just that.

This will come in handy later.

Join lines Mac + shift + j

We want to write the return statement of _4_thundercats() on just one line. Don’t use a sequence of Mac + , Macdelete combinations. Instead, first select all the thundercats’ names (the strings), then press Mac + shift + j (for Join lines).

HINT:
use Mac + right after the { character.

You might have to repeat the Mac + shift + j combination, because IntelliJ’s auto-formatting tends to kick in sometimes.


Next Chapter

Back to outline