(an hour later)

"Terrific! Where did we stop?"

"The code inside a method or something like that."

"Right. Exactly. The body of a method consists of commands. We could even say that a method is a group of commands that has been given a name (method name). Both statements would be true."

"There are all sorts of commands. Are there dogs on your planet?"

"Only domesticated robotic wolves."

"Do they execute commands?"

"Yep. 'Bite', 'Eat', 'Tear', and 'Good! Heel!'"

Ready for the first program - 1

"Hmm. Nice commands! But there aren't very many of them."

"How many do we need?"

"The Java language has commands for every occasion. Each command describes some action. At the end of each command, we use a semicolon."

"Here are some examples of commands:"

Command Description (what it does)
Displays the number 1 on the screen
Displays "Amigo" on the screen
System.out.println("Rishi & Amigo");
Displays "Rishi & Amigo" on the screen

"Actually, this is just one command System.out.println. We use parentheses to pass arguments to the command. Depending on the value of the arguments, the same command can execute different actions."

"That's very convenient."

"Yes. If you want to display some text on the screen, you put double quotes on each side of it.

A single quotation mark looks like this: '. A double quotation mark looks like this: ". A double quotation mark is not the same thing as two single quotation marks. Please don't confuse them."

"The key for the double quotation mark is next to the Enter button on the keyboard, right?"


Amigo’s pulse accelerated from 3 to 5 GHz. He still couldn’t believe it. He had just learned how to print strings on the screen, and it turned out to be much easier that he had expected.
Amigo looked out the window to distract himself from his thoughts and calm down. The leaves were turning yellow. The Rusty Season is very close, he noted automatically. An illuminator let him see much further than usual. The newcomers’ technology was very advanced indeed. But did he care about the leaves now? He would multiply his knowledge again by evening!

Ready for the first program - 2

But his thoughts wouldn’t calm down. One day, he’d write a program to make all robots take refuge in their homes during the Rusty Season. That program alone would save thousands of robo-lives…

"This command has two versions: System.out.println() and System.out.print()"

"If you use the System.out.println() command a few times, you’ll see that each time the text you pass to the command is displayed on a separate line. If you use the System.out.print() command, the text is displayed on the same line. For example:"

Commands What will be displayed on the screen
System.out.println("Is The");
Is The
System.out.println("Is The");
AmigoIs The
System.out.print("Is The");
AmigoIs TheBest

"Keep this in mind: println doesn't start printing text from a new line. It prints text on the current line, but makes it so the next text will be printed on a new line."

"The println() command prints the text on the screen and adds a special unseen 'newline character'. This is what makes the next text start on a new line."

"What does the entire program look like?"

"Look at the screen:"

public class Home
    public static void main(String[] args)
        System.out.print("Amigo ");
        System.out.print("Is The ");

"Oh! It's all clear. We added spaces to the ends of the words so they wouldn’t all run together, right?"

"Exactly. You’re a smart little guy."

The comment made Amigo radiate with pride.

"Great. Here’s a task for you.."