נבנה על ידיBuilt by Ariel Yohimovich

JavaJava
1
חלקPart 1: יסודותFoundations כ-3 שעות (כולל הפסקה)About 3 hours (with a break)

מה זה תכנות? JVM, JDK, IntelliJ ו-jshellWhat is programming? JVM, JDK, IntelliJ & jshell

איך מחשב מבצע הוראות, איך Java רצה (קוד, javac, bytecode, JVM), התקנת JDK ו-IntelliJ ב-Windows וב-Mac, jshell, והתוכנית הראשונה.

How a computer follows instructions, how Java runs (source, javac, bytecode, the JVM), installing the JDK and IntelliJ on Windows and Mac, jshell, and a first program.

נסו לפתור לבד לפני שמציצים. בנגן: חיצים במקלדת או הכפתורים. כל צעד מראה איפה (קובץ ושורה), מה כותבים ולמה.Try on your own before peeking. In the player use the arrow keys or the buttons. Each step shows where (file and line), what to write, and why.
תרגילExercise 1

מכינים את המחשבSet up your computer

תזכורת: מה ביקשוReminder: the task

במחשב שלכם: התקינו JDK 21 ובדקו את הגרסאות. צרו על שולחן העבודה תיקייה בשם java-course, צרו בה (בכל עורך) קובץ Hello.java עם תוכנית שמדפיסה Hi, ואז קמפלו והריצו מהטרמינל.

On your own computer: install JDK 21 and check the versions. Create a folder named java-course on the Desktop, create Hello.java in it (in any editor) with a program that prints Hi, then compile and run it from the terminal.

סרטון מונפש: על מה לוחצים, מה כותבים ולמה, צעד אחר צעד.An animated movie: what to click, what to type and why, step by step.
איפהWhere
מהWhat
למהWhy
הפתרון המלא והפלט שלוFull solution and its output
Terminal
java --version
cd Desktop
mkdir java-course
cd java-course
# כאן יוצרים את Hello.java בעורך ושומרים
javac Hello.java
java Hello
java --version
cd Desktop
mkdir java-course
cd java-course
# create Hello.java in an editor and save it here
javac Hello.java
java Hello

יש יותר מדרך נכונה אחת. אם הפלט שלכם זהה, גם הפתרון שלכם נכון.There is more than one right way. If your output matches, your solution is right too.

תרגילExercise 2

שלום, עולם (בגרסה שלכם)Hello, world (your version)

תזכורת: מה ביקשוReminder: the task

כתבו תוכנית שמדפיסה שתי שורות: ברכה עם השם שלכם, ומשפט על משהו שאתם אוהבים.

Write a program that prints two lines: a greeting with your name, and a sentence about something you love.

סרטון מונפש: על מה לוחצים, מה כותבים ולמה, צעד אחר צעד.An animated movie: what to click, what to type and why, step by step.
איפהWhere
מהWhat
למהWhy

סימולציה: הפתרון רץ שורה אחרי שורהSimulation: the solution runs line by line

לוחצים הבא או נגן: רואים איזו שורה Java מבצעת, מה יש בכל קופסה (משתנה) ומה מופיע על המסך. זו הרצה אמיתית של הפתרון.

Press Next or Play: see which line Java runs, what is in each box (variable) and what appears on the screen. This is a real run of the solution.

צפו בהרצה צעד אחר צעדWatch it run, step by step
צפו בהרצהWatch it runשורה אחרי שורה, כמו ש-Java מבצעתLine by line, the way Java runs it

מה קורה עכשיוWhat happens now

הקופסאות (משתנים)The boxes (variables)

מסך הפלטOutput screen

הפתרון המלא והפלט שלוFull solution and its output
Main.java
public class Main {
    public static void main(String[] args) {
        System.out.println("שלום, אני נועה!");
        System.out.println("אני אוהבת פיצה וטיולים");
    }
}
public class Main {
    public static void main(String[] args) {
        System.out.println("Hi, I am Noa!");
        System.out.println("I love pizza and hiking");
    }
}
פלטOutput
שלום, אני נועה!
אני אוהבת פיצה וטיולים
Hi, I am Noa!
I love pizza and hiking

יש יותר מדרך נכונה אחת. אם הפלט שלכם זהה, גם הפתרון שלכם נכון.There is more than one right way. If your output matches, your solution is right too.

תרגילExercise 3

כרטיס ביקורBusiness card

תזכורת: מה ביקשוReminder: the task

הדפיסו כרטיס ביקור של 5 שורות לפחות: קו עליון, שם, תפקיד (למשל "מפתח/ת Java מתחיל/ה"), אימייל וקו תחתון. הוסיפו הערה אחת עם // שמסבירה מה התוכנית עושה.

Print a business card of at least 5 lines: a top border, a name, a role (e.g. "Beginner Java developer"), an email and a bottom border. Add one // comment explaining what the program does.

סרטון מונפש: על מה לוחצים, מה כותבים ולמה, צעד אחר צעד.An animated movie: what to click, what to type and why, step by step.
איפהWhere
מהWhat
למהWhy

סימולציה: הפתרון רץ שורה אחרי שורהSimulation: the solution runs line by line

לוחצים הבא או נגן: רואים איזו שורה Java מבצעת, מה יש בכל קופסה (משתנה) ומה מופיע על המסך. זו הרצה אמיתית של הפתרון.

Press Next or Play: see which line Java runs, what is in each box (variable) and what appears on the screen. This is a real run of the solution.

צפו בהרצה צעד אחר צעדWatch it run, step by step
צפו בהרצהWatch it runשורה אחרי שורה, כמו ש-Java מבצעתLine by line, the way Java runs it

מה קורה עכשיוWhat happens now

הקופסאות (משתנים)The boxes (variables)

מסך הפלטOutput screen

הפתרון המלא והפלט שלוFull solution and its output
Main.java
public class Main {
    public static void main(String[] args) {
        // מדפיס כרטיס ביקור
        System.out.println("-------------------------");
        System.out.println("נועה לוי");
        System.out.println("מפתחת Java מתחילה");
        System.out.println("noa@example.com");
        System.out.println("-------------------------");
    }
}
public class Main {
    public static void main(String[] args) {
        // Prints a business card
        System.out.println("-------------------------");
        System.out.println("Noa Levi");
        System.out.println("Beginner Java developer");
        System.out.println("noa@example.com");
        System.out.println("-------------------------");
    }
}
פלטOutput
-------------------------
נועה לוי
מפתחת Java מתחילה
noa@example.com
-------------------------
-------------------------
Noa Levi
Beginner Java developer
noa@example.com
-------------------------

יש יותר מדרך נכונה אחת. אם הפלט שלכם זהה, גם הפתרון שלכם נכון.There is more than one right way. If your output matches, your solution is right too.

תרגילExercise 4

ציור ASCIIASCII art

תזכורת: מה ביקשוReminder: the task

ציירו בפלט חתול, בית או רובוט, בעזרת תווים רגילים בלבד. לפחות 5 שורות.

Draw a cat, a house or a robot in the output, using plain characters only. At least 5 lines.

סרטון מונפש: על מה לוחצים, מה כותבים ולמה, צעד אחר צעד.An animated movie: what to click, what to type and why, step by step.
איפהWhere
מהWhat
למהWhy

סימולציה: הפתרון רץ שורה אחרי שורהSimulation: the solution runs line by line

לוחצים הבא או נגן: רואים איזו שורה Java מבצעת, מה יש בכל קופסה (משתנה) ומה מופיע על המסך. זו הרצה אמיתית של הפתרון.

Press Next or Play: see which line Java runs, what is in each box (variable) and what appears on the screen. This is a real run of the solution.

צפו בהרצה צעד אחר צעדWatch it run, step by step
צפו בהרצהWatch it runשורה אחרי שורה, כמו ש-Java מבצעתLine by line, the way Java runs it

מה קורה עכשיוWhat happens now

הקופסאות (משתנים)The boxes (variables)

מסך הפלטOutput screen

הפתרון המלא והפלט שלוFull solution and its output
Main.java
public class Main {
    public static void main(String[] args) {
        System.out.println("  /\\_/\\  ");
        System.out.println(" ( o.o ) ");
        System.out.println("  > ^ <  ");
        System.out.println(" /     \\ ");
        System.out.println("(_______)");
    }
}
פלטOutput
  /\_/\  
 ( o.o ) 
  > ^ <  
 /     \ 
(_______)

יש יותר מדרך נכונה אחת. אם הפלט שלכם זהה, גם הפתרון שלכם נכון.There is more than one right way. If your output matches, your solution is right too.

תרגילExercise 5

מחשבון זמניםTime calculator

תזכורת: מה ביקשוReminder: the task

הדפיסו, עם כיתוב ברור, כמה שעות יש בשבוע וכמה דקות יש ביממה. Java צריכה לחשב, לא אתם!

Print, with clear labels, how many hours are in a week and how many minutes are in a day. Let Java calculate, not you!

סרטון מונפש: על מה לוחצים, מה כותבים ולמה, צעד אחר צעד.An animated movie: what to click, what to type and why, step by step.
איפהWhere
מהWhat
למהWhy

סימולציה: הפתרון רץ שורה אחרי שורהSimulation: the solution runs line by line

לוחצים הבא או נגן: רואים איזו שורה Java מבצעת, מה יש בכל קופסה (משתנה) ומה מופיע על המסך. זו הרצה אמיתית של הפתרון.

Press Next or Play: see which line Java runs, what is in each box (variable) and what appears on the screen. This is a real run of the solution.

צפו בהרצה צעד אחר צעדWatch it run, step by step
צפו בהרצהWatch it runשורה אחרי שורה, כמו ש-Java מבצעתLine by line, the way Java runs it

מה קורה עכשיוWhat happens now

הקופסאות (משתנים)The boxes (variables)

מסך הפלטOutput screen

הפתרון המלא והפלט שלוFull solution and its output
Main.java
public class Main {
    public static void main(String[] args) {
        System.out.println("שעות בשבוע: " + (7 * 24));
        System.out.println("דקות ביממה: " + (24 * 60));
    }
}
public class Main {
    public static void main(String[] args) {
        System.out.println("Hours in a week: " + (7 * 24));
        System.out.println("Minutes in a day: " + (24 * 60));
    }
}
פלטOutput
שעות בשבוע: 168
דקות ביממה: 1440
Hours in a week: 168
Minutes in a day: 1440

יש יותר מדרך נכונה אחת. אם הפלט שלכם זהה, גם הפתרון שלכם נכון.There is more than one right way. If your output matches, your solution is right too.

תרגילExercise 6

צייד באגיםBug hunter

תזכורת: מה ביקשוReminder: the task

בקוד הזה יש 3 באגים. לחצו הרצה, קראו את ההודעות של javac, ותקנו עד שהתוכנית מדפיסה 3 שורות. טיפ: המהדר מראה קודם שגיאות תחביר, ורק אחרי שהן מתוקנות הוא מוצא שמות לא נכונים.

This code has 3 bugs. Press Run, read javac's messages, and fix them until the program prints 3 lines. Tip: the compiler shows syntax errors first, and only after they're fixed does it find wrong names.

סרטון מונפש: על מה לוחצים, מה כותבים ולמה, צעד אחר צעד.An animated movie: what to click, what to type and why, step by step.
איפהWhere
מהWhat
למהWhy

סימולציה: הפתרון רץ שורה אחרי שורהSimulation: the solution runs line by line

לוחצים הבא או נגן: רואים איזו שורה Java מבצעת, מה יש בכל קופסה (משתנה) ומה מופיע על המסך. זו הרצה אמיתית של הפתרון.

Press Next or Play: see which line Java runs, what is in each box (variable) and what appears on the screen. This is a real run of the solution.

צפו איפה זה נשברWatch where it breaks
איפה זה נשברWhere it breaksשורה אחרי שורה, כמו ש-Java מבצעתLine by line, the way Java runs it

מה קורה עכשיוWhat happens now

הקופסאות (משתנים)The boxes (variables)

מסך הפלטOutput screen

צפו בהרצה צעד אחר צעדWatch it run, step by step
צפו בהרצהWatch it runשורה אחרי שורה, כמו ש-Java מבצעתLine by line, the way Java runs it

מה קורה עכשיוWhat happens now

הקופסאות (משתנים)The boxes (variables)

מסך הפלטOutput screen

הפתרון המלא והפלט שלוFull solution and its output
Main.java
public class Main {
    public static void main(String[] args) {
        System.out.println("מתחילים!");
        System.out.println("2 * 21 = " + 2 * 21);
        System.out.println("סוף");
    }
}
public class Main {
    public static void main(String[] args) {
        System.out.println("Let's go!");
        System.out.println("2 * 21 = " + 2 * 21);
        System.out.println("The end");
    }
}
פלטOutput
מתחילים!
2 * 21 = 42
סוף
Let's go!
2 * 21 = 42
The end

יש יותר מדרך נכונה אחת. אם הפלט שלכם זהה, גם הפתרון שלכם נכון.There is more than one right way. If your output matches, your solution is right too.

תרגילExercise 7

print מול printlnprint vs println

תזכורת: מה ביקשוReminder: the task

הדפיסו את השורה 1 2 3 GO! בעזרת ארבע פקודות הדפסה: שלוש print ו-println אחת. אחר כך, בשורה נפרדת, הדפיסו done.

Print the line 1 2 3 GO! using four print commands: three print and one println. Then, on a separate line, print done.

סרטון מונפש: על מה לוחצים, מה כותבים ולמה, צעד אחר צעד.An animated movie: what to click, what to type and why, step by step.
איפהWhere
מהWhat
למהWhy

סימולציה: הפתרון רץ שורה אחרי שורהSimulation: the solution runs line by line

לוחצים הבא או נגן: רואים איזו שורה Java מבצעת, מה יש בכל קופסה (משתנה) ומה מופיע על המסך. זו הרצה אמיתית של הפתרון.

Press Next or Play: see which line Java runs, what is in each box (variable) and what appears on the screen. This is a real run of the solution.

צפו בהרצה צעד אחר צעדWatch it run, step by step
צפו בהרצהWatch it runשורה אחרי שורה, כמו ש-Java מבצעתLine by line, the way Java runs it

מה קורה עכשיוWhat happens now

הקופסאות (משתנים)The boxes (variables)

מסך הפלטOutput screen

הפתרון המלא והפלט שלוFull solution and its output
Main.java
public class Main {
    public static void main(String[] args) {
        System.out.print("1 ");
        System.out.print("2 ");
        System.out.print("3 ");
        System.out.println("GO!");
        System.out.println("done");
    }
}
פלטOutput
1 2 3 GO!
done

יש יותר מדרך נכונה אחת. אם הפלט שלכם זהה, גם הפתרון שלכם נכון.There is more than one right way. If your output matches, your solution is right too.

תרגילExercise 8

מדף, צעד 1: באנר וספר ראשוןShelf, step 1: banner and first book

תזכורת: מה ביקשוReminder: the task

מתחילים את הפרויקט המלווה, מדף: ספרייה אישית. הדפיסו באנר פתיחה בין שני קווים, ואחריו ספר אחד בשורה בפורמט שם הספר - סופר (שנה). את השנה כתבו כמספר, ובשורה האחרונה הדפיסו כמה שנים עברו מאז שהספר יצא, כש-Java מחשבת (השתמשו ב-2026).

Start the companion project, Shelf: a personal library. Print a welcome banner between two lines, then one book on a line in the format Title - Author (Year). Write the year as a number, and on the last line print how many years have passed since the book came out, with Java doing the maths (use 2026).

סרטון מונפש: על מה לוחצים, מה כותבים ולמה, צעד אחר צעד.An animated movie: what to click, what to type and why, step by step.
איפהWhere
מהWhat
למהWhy

סימולציה: הפתרון רץ שורה אחרי שורהSimulation: the solution runs line by line

לוחצים הבא או נגן: רואים איזו שורה Java מבצעת, מה יש בכל קופסה (משתנה) ומה מופיע על המסך. זו הרצה אמיתית של הפתרון.

Press Next or Play: see which line Java runs, what is in each box (variable) and what appears on the screen. This is a real run of the solution.

צפו בהרצה צעד אחר צעדWatch it run, step by step
צפו בהרצהWatch it runשורה אחרי שורה, כמו ש-Java מבצעתLine by line, the way Java runs it

מה קורה עכשיוWhat happens now

הקופסאות (משתנים)The boxes (variables)

מסך הפלטOutput screen

הפתרון המלא והפלט שלוFull solution and its output
Main.java
public class Main {
    public static void main(String[] args) {
        System.out.println("==============================");
        System.out.println("   מדף: הספרייה האישית שלי");
        System.out.println("==============================");
        System.out.println("הנסיך הקטן - Antoine de Saint-Exupéry (" + 1943 + ")");
        System.out.println("שנים מאז שיצא: " + (2026 - 1943));
    }
}
public class Main {
    public static void main(String[] args) {
        System.out.println("==============================");
        System.out.println("   Shelf: my personal library");
        System.out.println("==============================");
        System.out.println("The Little Prince - Antoine de Saint-Exupéry (" + 1943 + ")");
        System.out.println("Years since it came out: " + (2026 - 1943));
    }
}
פלטOutput
==============================
   מדף: הספרייה האישית שלי
==============================
הנסיך הקטן - Antoine de Saint-Exupéry (1943)
שנים מאז שיצא: 83
==============================
   Shelf: my personal library
==============================
The Little Prince - Antoine de Saint-Exupéry (1943)
Years since it came out: 83

יש יותר מדרך נכונה אחת. אם הפלט שלכם זהה, גם הפתרון שלכם נכון.There is more than one right way. If your output matches, your solution is right too.

אתגרChallenge 1

מפרקים שניותBreaking down seconds

תזכורת: מה ביקשוReminder: the task

מרתון של סרטים נמשך 100000 שניות. בלי לחשב בראש, הדפיסו בשורה אחת כמה ימים, שעות, דקות ושניות זה, למשל 1 days, 3 hours, 46 minutes, 40 seconds. השתמשו רק ב-/ וב-% של מספרים שלמים.

A movie marathon lasts 100000 seconds. Without doing the maths yourself, print on one line how many days, hours, minutes and seconds that is, e.g. 1 days, 3 hours, 46 minutes, 40 seconds. Use only whole-number / and %.

סרטון מונפש: על מה לוחצים, מה כותבים ולמה, צעד אחר צעד.An animated movie: what to click, what to type and why, step by step.
איפהWhere
מהWhat
למהWhy

סימולציה: הפתרון רץ שורה אחרי שורהSimulation: the solution runs line by line

לוחצים הבא או נגן: רואים איזו שורה Java מבצעת, מה יש בכל קופסה (משתנה) ומה מופיע על המסך. זו הרצה אמיתית של הפתרון.

Press Next or Play: see which line Java runs, what is in each box (variable) and what appears on the screen. This is a real run of the solution.

צפו בהרצה צעד אחר צעדWatch it run, step by step
צפו בהרצהWatch it runשורה אחרי שורה, כמו ש-Java מבצעתLine by line, the way Java runs it

מה קורה עכשיוWhat happens now

הקופסאות (משתנים)The boxes (variables)

מסך הפלטOutput screen

הפתרון המלא והפלט שלוFull solution and its output
Main.java
public class Main {
    public static void main(String[] args) {
        System.out.print((100000 / 86400) + " ימים, ");
        System.out.print(((100000 % 86400) / 3600) + " שעות, ");
        System.out.print(((100000 % 3600) / 60) + " דקות, ");
        System.out.println((100000 % 60) + " שניות");
    }
}
public class Main {
    public static void main(String[] args) {
        System.out.print((100000 / 86400) + " days, ");
        System.out.print(((100000 % 86400) / 3600) + " hours, ");
        System.out.print(((100000 % 3600) / 60) + " minutes, ");
        System.out.println((100000 % 60) + " seconds");
    }
}
פלטOutput
1 ימים, 3 שעות, 46 דקות, 40 שניות
1 days, 3 hours, 46 minutes, 40 seconds

יש יותר מדרך נכונה אחת. אם הפלט שלכם זהה, גם הפתרון שלכם נכון.There is more than one right way. If your output matches, your solution is right too.

אתגרChallenge 2

פירמידת המספריםThe number pyramid

תזכורת: מה ביקשוReminder: the task

הדפיסו 5 שורות: 1 * 1, 11 * 11, 111 * 111 וכן הלאה עד 11111 * 11111 (רק Java מחשבת!). מה מיוחד בתוצאות? כתבו את התשובה בהערה בסוף הקוד.

Print 5 lines: 1 * 1, 11 * 11, 111 * 111 and so on up to 11111 * 11111 (Java does the maths!). What's special about the results? Write the answer in a comment at the end of the code.

סרטון מונפש: על מה לוחצים, מה כותבים ולמה, צעד אחר צעד.An animated movie: what to click, what to type and why, step by step.
איפהWhere
מהWhat
למהWhy

סימולציה: הפתרון רץ שורה אחרי שורהSimulation: the solution runs line by line

לוחצים הבא או נגן: רואים איזו שורה Java מבצעת, מה יש בכל קופסה (משתנה) ומה מופיע על המסך. זו הרצה אמיתית של הפתרון.

Press Next or Play: see which line Java runs, what is in each box (variable) and what appears on the screen. This is a real run of the solution.

צפו בהרצה צעד אחר צעדWatch it run, step by step
צפו בהרצהWatch it runשורה אחרי שורה, כמו ש-Java מבצעתLine by line, the way Java runs it

מה קורה עכשיוWhat happens now

הקופסאות (משתנים)The boxes (variables)

מסך הפלטOutput screen

הפתרון המלא והפלט שלוFull solution and its output
Main.java
public class Main {
    public static void main(String[] args) {
        System.out.println(1 * 1);
        System.out.println(11 * 11);
        System.out.println(111 * 111);
        System.out.println(1111 * 1111);
        System.out.println(11111 * 11111);
        // כל תוצאה היא פלינדרום: עולה עד מספר האחדות ויורדת חזרה
    }
}
public class Main {
    public static void main(String[] args) {
        System.out.println(1 * 1);
        System.out.println(11 * 11);
        System.out.println(111 * 111);
        System.out.println(1111 * 1111);
        System.out.println(11111 * 11111);
        // each result is a palindrome: it climbs to the number of ones and comes back down
    }
}
פלטOutput
1
121
12321
1234321
123454321
1
121
12321
1234321
123454321

יש יותר מדרך נכונה אחת. אם הפלט שלכם זהה, גם הפתרון שלכם נכון.There is more than one right way. If your output matches, your solution is right too.

נבנה על ידיBuilt by Ariel Yohimovich