"สวัสดี นี่ฉันเองนะ วันนี้ฉันจะให้บทเรียน 3 บทเรียน และนี่คือบทเรียนที่สอง! ทำใจให้สบายและตั้งใจฟัง ฉันจะบอกคุณเกี่ยวกับการแสดงข้อความบนหน้าจอ จริงๆ แล้วง่ายมาก:"

รหัสจาวา สิ่งที่จะแสดงบนหน้าจอ
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() เพื่อหยุดการแสดงข้อความในบรรทัดปัจจุบันก่อนที่จะเต็ม ข้อความต่อมา จะปรากฏในบรรทัดถัดไป"

"ตกลง แล้วเคล็ดลับในการบวกตัวเลขและสตริงคืออะไร"

"ถ้าคุณบวกเลขสองตัว ผลลัพธ์ที่ได้จะเป็นตัวเลขด้วย: 2+2 เท่ากับ 4 ถ้าคุณบวกตัวเลขและสตริง ตัวเลขนั้นจะถูกแปลงเป็นสตริง จากนั้นสตริงทั้งสองจะรวมเข้าด้วยกัน"

"โอ้! นั่นคือสิ่งที่ฉันคิดจากการดูตัวอย่าง แต่ใครจะรู้ ขอบคุณสำหรับบทเรียนที่น่าสนใจนี้ เอลลี่"

"ยินดีต้อนรับ และสุดท้าย นี่คืองานบางส่วนจากดิเอโก เขาต้องการให้ฉันตรวจสอบความคืบหน้าของคุณ"

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.