print() and println();

"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
System.out.println("Rain" + "In" + "Spain");
System.out.println(1 + 3);
System.out.println("1" + "3");
System.out.println(1 + "3");
System.out.println("1" + 3);
System.out.println("1" + (1 + 3));
System.out.println("Amigo is the best!");
System.out.println("Amigo" + "is the best!");
System.out.println("Amigo" + " " + "is the best!");
Amigo is the best!
Amigois the best!
Amigo is the best!
System.out.println(3 * 3 + 4 * 4);
System.out.println(1 * 2 + 3 * 4);
System.out.print("Diego ");
System.out.println("is the best!");
System.out.print("Amigo ");
System.out.println("is the best!");
Diego is the best!
Amigo is the best!
Java Syntax,  level 1lesson 7
Code entry
Sometimes you don't need to think, you just need to hammer it out! As paradoxical as it may seem, sometimes your fingers will "remember" better than your conscious mind. That's why while training at the secret CodeGym center you will sometimes encounter tasks that require you to enter code. By entering code, you get used to the syntax and earn a little dark matter. What's more, you combat laziness!

"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."

Java Syntax,  level 1lesson 7
Finding bugs
If you show me someone who has never once made a programming error, we can say with certainty: you must not be talking about a human. Bug-free programming just doesn't happen. But this isn't so scary. The most important thing is to immediately accept that bugs are inevitable. We search for (or "catch", as professionals sometimes say) and correct bugs.
Java Syntax,  level 1lesson 7
We don't need any extra lines
Inexperienced and, at times, experienced programmers create superfluous code. Just in case. For example, they may declare a couple dozen variables and then not know what to do with them. In this task, someone did something weird, and we get to correct it. Look for unused variables and convert them to comments in order to hide from the compiler.
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Innocent O.Level 2 , Munich
yesterday, 15:15
How many levels can i complete within a month? And how long does it take to get to level 41 if i study 4 hours a day?
Gigi SuchanLevel 1 , Los Angeles
Thursday, 04:23
Is there any way to disable Achievements?
AlexLevel 41
day before yesterday, 10:29
Not at the moment, unfortunately, but we're working on it.
FormulaEagleLevel 2 , Rockville
27 June, 14:38
i cant get the lines one....
Demory GreenLevel 1 , Broken Arrow
13 June, 21:39
Can't go forward without buying premium subscription?
John SquirrelsLevel 41 , Richmond
15 June, 15:26
Hi. You can enjoy the Games section and Level 0 of our course for free. In order to continue with the course after Level 0, you will require one of our paid subscriptions.
YgnacioLevel 2 , Ciudad Guayana
12 June, 17:19
You need a Premium subscription to access the task.
John SquirrelsLevel 41 , Richmond
15 June, 15:26
Hi. You can enjoy the Games section and Level 0 of our course for free. In order to continue with the course after Level 0, you will require one of our paid subscriptions.
Fausto Gonzalez MoralesLevel 2 , Vancouver
3 June, 22:11
It confused me when it said that the program should display text.
Maryem VickersLevel 4 , Coalisland
8 June, 16:08
Hahahah same!
Fuzzy_MelonLevel 9
6 April, 19:10
Drive by...
Tanish AnandababuLevel 2 , Pune
6 April, 11:14
wonderful re baba
AbracadaverLevel 3 , Minneapolis
31 March, 00:05
cant get it to work after changing to lowercase "L"n and trying many times. moving on!
felipe romeroLevel 2 , Gainesville
7 April, 23:27
try adding // to comment out some lines that are not needed
JonathanLevel 7 , Wakiso
11 April, 04:36
System.out.println("l is lower case L in println")
Rismitha IsmailLevel 2 , Mumbai
16 February, 07:58
im unable to complete the last task which is code entry. I have entered the codes properly still none of the processing was done. how to get complete ????
Amit SharmaLevel 9 , Mumbai
12 March, 12:05
You have to copy the exact same code, even an extra space should not be there.