"Hi, it's me again. I'll give you three lessons today. And this is the second one! Make yourself comfortable and listen up. I'm going to tell you about displaying text on the screen. It's actually very simple:"
Java code | What will be displayed on the screen |
---|---|
|
Diego 3 RainInSpain |
|
4 13 13 13 14 |
|
Amigo is the best! Amigois the best! Amigo is the best! |
|
25 14 |
|
DiegoDiegoDiego |
|
Diego is the best! Amigo is the best! |
"Could you tell me about print() and println() one more time?"
"The print(), function is used to display text on the screen, character by character. When the screen no longer has room on a line, the text begins to be displayed on the next line. You can use the println() function to stop displaying text on the current line even before it is full. Subsequent text will appear on the next line."
"OK. And what was that trick with adding numbers and strings?"
"If you add two numbers, the result is also a number: 2+2 equals 4. If you add a number and a string, the number is converted to a string. Then the two strings are simply joined together."
"Oh! That's what I thought from looking at the examples, but who knows. Thank you for this interesting lesson, Ellie."
"You're welcome. And finally, here are a few tasks from Diego. He wanted me to check your progress."
GO TO FULL VERSION