ตัวอย่างการบรรยายพร้อมผู้ให้คำปรึกษาซึ่งเป็นส่วนหนึ่งของหลักสูตร Codegym University ลงทะเบียนสำหรับหลักสูตรเต็ม


"สวัสดี อามีโก้"

“สวัสดี เอเลนอร์ แคร์รี่”

“เรียกฉันว่าเอลลี่ก็ได้ ไม่จำเป็นต้องเป็นทางการขนาดนั้นก็ได้”

“ตกลง เอลลี่”

"ฉันเชื่อว่าด้วยความช่วยเหลือของฉัน คุณจะเป็นหนึ่งในคนที่เก่งที่สุดในไม่ช้า ฉันมีประสบการณ์มากมายในการฝึกมือใหม่ อยู่กับฉันแล้วทุกอย่างจะดีขึ้น เอาล่ะ มาเริ่มกันเลย"

"มีสองประเภทหลักในJava : String และ intเราเก็บสตริง/ข้อความไว้ใน String และจำนวนเต็ม (จำนวนเต็ม) ใน int ในการประกาศตัวแปรใหม่ คุณต้องระบุประเภทและชื่อของมันชื่อไม่สามารถเป็น เช่นเดียวกับชื่อของตัวแปรและ/หรือฟังก์ชันอื่นๆ"

ตัวอย่างที่ 1 รหัส: คำอธิบาย
String s;
sมีการประกาศตัวแปรใหม่ สามารถจัดเก็บข้อความ
int i;
iมีการประกาศตัวแปรใหม่ สามารถเก็บจำนวนเต็มได้

"คุณสามารถกำหนดค่าให้กับตัวแปรเมื่อคุณประกาศ"

ตัวอย่างที่ 2 รหัส: คำอธิบาย
String s = "Ellie";
ตัวแปรเก็บsสตริง"Ellie"
int i = 5;
ตัวแปรiเก็บหมายเลข 5

"ในการกำหนดค่าใหม่ให้กับตัวแปร เราใช้=เครื่องหมาย เรียกอีกอย่างว่า'ตัวดำเนินการมอบหมาย' การมอบหมายหมายถึงการใส่ค่าจากตัวแปรอื่นหรือค่าที่คำนวณจากหลายตัวแปรลงในตัวแปร"

ตัวอย่างที่ 3 รหัส: คำอธิบาย
int a = 5;
ตัวแปรaเก็บค่า5.
int b = 6;
ตัวแปรbเก็บค่า6.
int c = a + b;
ตัวแปรcเก็บค่า11.

"สามารถใช้ค่าของตัวแปรเพื่อคำนวณค่าใหม่ที่จะมาแทนที่ค่าเก่า"

ตัวอย่างที่ 4 รหัส: คำอธิบาย
int a = 2;
ตอนนี้aเท่ากับ 2
int b = 3;
ตอนนี้bเท่ากับ 3
a = a + b;
ตอนนี้aเท่ากับ 5
b = b + 1;
ตอนนี้bเท่ากับ 4

"คุณสามารถรวมสตริงเข้ากับ+เครื่องหมาย:"

ตัวอย่างที่ 5 รหัส: คำอธิบาย
String s1 = "Rain";
String s2 = "In";
String s3 = s1 + s2 + "Spain";
ตัวแปรs3เก็บสตริง"RainInSpain"

"บางครั้ง สตริงที่ประกอบด้วยช่องว่างตั้งแต่หนึ่งช่องขึ้นไปอาจมีประโยชน์:"

ตัวอย่างที่ 6 รหัส: คำอธิบาย
String s1 = "My favorite movie is";
String s2 = "Route";
int roadNumber = 66;
String text = s1 + " " + s2 + " " + roadNumber;
textร้านค้า"My favorite movie is Route 66"

"มาดูวิธีที่เราแสดงข้อความและตัวแปรบนหน้าจอ:"

แนะนำ ints และ Strings - 1
ตัวอย่างที่ 7 รหัส:
1
System.out.println("A man's gotta do what a man's gotta do");
2
String s = "A man's gotta do what a man's gotta do";
System.out.println(s);

"ยังไงก็ตาม ดิเอโกขอให้ฉันออกกำลังกายสองสามอย่าง:"

1
งาน
Java Syntax,  ระดับบทเรียน
ล็อค
CodeGym. Learn once - use anywhere
Here's a riddle: "Written once, it runs everywhere". Answer: A Java program. That's the right answer, because Java is logical and properly structured. Let's rephrase this slogan for students: "learn once, use anywhere!" Here's a little task on this topic: write a program that displays a useful phrase 10 times on the screen.
1
งาน
โมดูล 1,  ระดับบทเรียน
ล็อค
Uh... Happy New Year!
What if you don't abandon your studies? What if you keep on completing tasks and working through the lessons? If you do, then by next New Year's, which is at least three months away, you can celebrate the new year as a real programmer! That's the dream. But for now, let's go to work. Let's remove the unnecessary comments and display some New Year's well-wishes.
1
งาน
Java Syntax,  ระดับบทเรียน
ล็อค
Let's change the code
Editing someone else's code is sometimes more difficult than writing your own. You can trust the experience of experts at the secret CodeGym center. That's why our curriculum includes tasks about fixing code. For now, let's open our textbook, wrap our brains around some simple code, and then change the code so that the variable name takes the value "Amigo".
1
งาน
Java Syntax,  ระดับบทเรียน
ล็อค
A few more corrections
Articles such as "1001 Tips for Becoming a Great Programmer" almost always include a phrase like "Someone else's code will teach you how to write your own". A programmer seldom works alone, so this advice is the plain truth. You won't get anywhere by ignoring it. We have to get used to teamwork and fixing other people's code.