נבנה על ידיBuilt by Ariel Yohimovich
int, long, double, boolean, char ועוד).primitive type: Java's 8 basic types (int, long, double, boolean, char and more).=.assignment: Putting a value in a box with =.= והערך.In Java you write the type first, then the name, then = and the value.= הוא השמה: "שים בקופסה".= is an assignment: "put in the box".= והערך. = הוא השמה: "שים בקופסה". אפשר לשים ערך חדש, והישן נמחק.In Java you write the type first, then the name, then = and the value. = is an assignment: "put in the box". You can put a new value in, and the old one is gone.int age = 15;
String name = "נועה";
System.out.println(name + " בת " + age);
age = age + 1;
System.out.println("בשנה הבאה: " + age);int age = 15;
String name = "Noa";
System.out.println(name + " is " + age);
age = age + 1;
System.out.println("Next year: " + age);int age = 15;
String name = "נועה";
System.out.println(name + " בת " + age);
age = age + 1;
System.out.println("בשנה הבאה: " + age);int age = 15;
String name = "Noa";
System.out.println(name + " is " + age);
age = age + 1;
System.out.println("Next year: " + age);נועה בת 15 בשנה הבאה: 16
Noa is 15 Next year: 16
int למספרים שלמים, double למספרים עם נקודה, boolean ל-true/false, char לתו אחד בין גרשיים בודדים, ו-long למספרים שלמים ענקיים (עם L בסוף).int for whole numbers, double for numbers with a point, boolean for true/false, char for one character in single quotes, and long for huge whole numbers (with an L at the end).int למספרים שלמים, double למספרים עם נקודה, boolean ל-true/false, char לתו אחד בין גרשיים בודדים, ו-long למספרים שלמים ענקיים (עם L בסוף).int for whole numbers, double for numbers with a point, boolean for true/false, char for one character in single quotes, and long for huge whole numbers (with an L at the end).int ל-double Java ממירה לבד (אין מה לאבד).From int to double Java converts by itself (nothing is lost).Math.round.To round: Math.round.int ל-double Java ממירה לבד (אין מה לאבד). בכיוון ההפוך צריך המרה מפורשת (cast) מפורש, והחלק העשרוני נחתך (לא מעוגל). לעיגול: Math.round.From int to double Java converts by itself (nothing is lost). The other way needs an explicit cast, and the decimal part is cut off (not rounded). To round: Math.round.int מגיע עד 2147483647.int goes up to 2147483647.long.For big numbers use long.int מגיע עד 2147483647. אם עוברים אותו, אין שגיאה: התוצאה פשוט "מתגלגלת" למספר שלילי (גלישה). למספרים גדולים משתמשים ב-long.int goes up to 2147483647. Go past it and there's no error: the result just "wraps around" to a negative number (overflow). For big numbers use long.int big = Integer.MAX_VALUE;
System.out.println(big);
big = big + 1;
System.out.println(big);
long safe = Integer.MAX_VALUE + 1L;
System.out.println(safe);int big = Integer.MAX_VALUE;
System.out.println(big);
big = big + 1;
System.out.println(big);
long safe = Integer.MAX_VALUE + 1L;
System.out.println(safe);2147483647 -2147483648 2147483648
var נותן למהדר להסיק את הטיפוס מהערך, אבל הטיפוס עדיין קבוע.var lets the compiler infer the type from the value, but the type is still fixed.final נועל את הקופסה אחרי ההשמה הראשונה.final locks the box after the first assignment.var נותן למהדר להסיק את הטיפוס מהערך, אבל הטיפוס עדיין קבוע. final נועל את הקופסה אחרי ההשמה הראשונה. קבועים כותבים באותיות גדולות.var lets the compiler infer the type from the value, but the type is still fixed. final locks the box after the first assignment. Constants go in capitals.String title, String author, int year, double rating ו-boolean read. הדפיסו כרטיס של 4 שורות: שם וסופר, שנה, Rating: 4.5/5, ו-Read: true.Keep one book in variables: String title, String author, int year, double rating and boolean read. Print a 4-line card: title and author, year, Rating: 4.5/5, and Read: true.int, long, double, boolean, char ועוד).primitive type: Java's 8 basic types (int, long, double, boolean, char and more).=.assignment: Putting a value in a box with =.= והערך.In Java you write the type first, then the name, then = and the value.= הוא השמה: "שים בקופסה".= is an assignment: "put in the box".int למספרים שלמים, double למספרים עם נקודה, boolean ל-true/false, char לתו אחד בין גרשיים בודדים, ו-long למספרים שלמים ענקיים (עם L בסוף).int for whole numbers, double for numbers with a point, boolean for true/false, char for one character in single quotes, and long for huge whole numbers (with an L at the end).int ל-double Java ממירה לבד (אין מה לאבד).From int to double Java converts by itself (nothing is lost).Math.round.To round: Math.round.int מגיע עד 2147483647.int goes up to 2147483647.long.For big numbers use long.var נותן למהדר להסיק את הטיפוס מהערך, אבל הטיפוס עדיין קבוע.var lets the compiler infer the type from the value, but the type is still fixed.final נועל את הקופסה אחרי ההשמה הראשונה.final locks the box after the first assignment.7710101414xx1010(int) 9.99?What is the value of (int) 9.99?1010999.999.9999= והערך.In Java you write the type first, then the name, then = and the value.int למספרים שלמים, double למספרים עם נקודה, boolean ל-true/false, char לתו אחד בין גרשיים בודדים, ו-long למספרים שלמים ענקיים (עם L בסוף).int for whole numbers, double for numbers with a point, boolean for true/false, char for one character in single quotes, and long for huge whole numbers (with an L at the end).int ל-double Java ממירה לבד (אין מה לאבד).From int to double Java converts by itself (nothing is lost).int מגיע עד 2147483647.int goes up to 2147483647.var נותן למהדר להסיק את הטיפוס מהערך, אבל הטיפוס עדיין קבוע.var lets the compiler infer the type from the value, but the type is still fixed.נבנה על ידיBuilt by Ariel Yohimovich