„Здрасти, пак съм аз. Днес ще ти дам три урока. И това е вторият! Настани се удобно и слушай. Ще ти разкажа за показването на текст на екрана. Всъщност е много просто:“

Java code Какво ще се покаже на екрана
System.out.println("Diego");
System.out.println(3);
System.out.println("Rain" + "In" + "Spain");
Diego
3
RainInSpain
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));
4
13
13
13
14
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);
25
14
System.out.print("Diego");
System.out.print("Diego");
System.out.print("Diego");
DiegoDiegoDiego
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!

„Бихте ли ми казали още веднъж за print() и println() ?“

" Функцията print() се използва за показване на текст на екрана, символ по знак. Когато на екрана вече няма място за ред, текстът започва да се показва на следващия ред. Можете да използвате функцията println(). за да спрете показването на текст на текущия ред дори преди да е пълен. Следващият текст ще се появи на следващия ред."

"Добре. И Howъв беше този трик с добавянето на числа и низове?"

„Ако добавите две числа, резултатът също е число: 2+2 е равно на 4. Ако добавите число и низ, числото се преобразува в низ. Тогава двата низа просто се свързват заедно.“

„О! Това си помислих, като гледах примерите, но кой знае. Благодаря ти за този интересен урок, Ели.“

„Няма на Howво. И накрая, ето няколко задачи от Диего. Той искаше да проверя напредъка ти.“

1
Задача
Java Syntax,  нивоурок
Заключено
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.
1
Задача
Java Syntax,  нивоурок
Заключено
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.