נבנה על ידיBuilt by Ariel Yohimovich
null.NullPointerException: The exception when you reach a field or method through null.class Book מתארת מה יש לכל ספר: שדות (title, pages) ומתודות (describe).class Book describes what every book has: fields (title, pages) and methods (describe).new Book() יוצר עצם חדש עם שדות משלו.Every new Book() makes a new object with its own fields.describe, title הוא השדה של העצם שעליו קראו למתודה.Inside describe, title is the field of the object the method was called on.class Book מתארת מה יש לכל ספר: שדות (title, pages) ומתודות (describe). כל new Book() יוצר עצם חדש עם שדות משלו. בתוך describe, title הוא השדה של העצם שעליו קראו למתודה.class Book describes what every book has: fields (title, pages) and methods (describe). Every new Book() makes a new object with its own fields. Inside describe, title is the field of the object the method was called on.b = a מעתיק את החץ: שני המשתנים מצביעים על אותו ספר, ושינוי דרך b נראה דרך a.b = a copies the arrow: both variables point to the same book, and a change through b shows through a.c = null הוא חץ שלא מצביע לשום מקום.c = null is an arrow pointing nowhere.b = a מעתיק את החץ: שני המשתנים מצביעים על אותו ספר, ושינוי דרך b נראה דרך a. c = null הוא חץ שלא מצביע לשום מקום.b = a copies the arrow: both variables point to the same book, and a change through b shows through a. c = null is an arrow pointing nowhere.null.A new array of objects is full of null.b.title מנסה לקרוא שדה של כלום.When the loop reaches the empty cell, b.title tries to read a field of nothing.null. כשהלולאה מגיעה לתא הריק, b.title מנסה לקרוא שדה של כלום. Java 21 אומרת בדיוק מה היה null.A new array of objects is full of null. When the loop reaches the empty cell, b.title tries to read a field of nothing. Java 21 says exactly what was null.Cannot read field "title" because "b" is null:Cannot read field "title" because "b" is null:Book עם title, author, year, ומתודות String line() (Emma by Austen (1815)) ו-boolean isClassic() (לפני 1950). שימו במערך את Emma (Austen, 1815), Dune (Herbert, 1965) ו-Ulysses (Joyce, 1922), הדפיסו שורה לכל ספר, ובסוף Classics: 2.A class Book with title, author, year, and methods String line() (Emma by Austen (1815)) and boolean isClassic() (before 1950). Put Emma (Austen, 1815), Dune (Herbert, 1965) and Ulysses (Joyce, 1922) in an array, print a line per book, then Classics: 2.null.NullPointerException: The exception when you reach a field or method through null.class Book מתארת מה יש לכל ספר: שדות (title, pages) ומתודות (describe).class Book describes what every book has: fields (title, pages) and methods (describe).new Book() יוצר עצם חדש עם שדות משלו.Every new Book() makes a new object with its own fields.describe, title הוא השדה של העצם שעליו קראו למתודה.Inside describe, title is the field of the object the method was called on.b = a מעתיק את החץ: שני המשתנים מצביעים על אותו ספר, ושינוי דרך b נראה דרך a.b = a copies the arrow: both variables point to the same book, and a change through b shows through a.c = null הוא חץ שלא מצביע לשום מקום.c = null is an arrow pointing nowhere.null.A new array of objects is full of null.b.title מנסה לקרוא שדה של כלום.When the loop reaches the empty cell, b.title tries to read a field of nothing.Cannot read field "title" because "b" is null:Cannot read field "title" because "b" is null:new. b = a לא יוצר עצם.Right: two news. b = a creates no object.String title בעצם חדש שאף אחד לא נתן לו ערך?What's a String title field in a new object that nobody gave a value?""""nullnull"title""title"nullnulla ו-b מצביעים על אותו ספר. מה מודפס?a and b point to the same book. What's printed?XXnullnullXXPoint עם שדות int x, int y ומתודה double distance() שמחזירה את המרחק מראשית הצירים (Math.sqrt(x*x + y*y)).Write a class Point with fields int x, int y and a method double distance() returning the distance from the origin (Math.sqrt(x*x + y*y)).Dog עם name, age, מתודה String describe() שמחזירה למשל Rex is 3, ומתודה void birthday() שמעלה את הגיל.A class Dog with name, age, a method String describe() returning e.g.Account עם int balance, void deposit(int amount) ו-boolean withdraw(int amount), שמושכת רק אם יש מספיק ומחזירה האם הצליחה.A class Account with int balance, void deposit(int amount) and boolean withdraw(int amount), which withdraws only if there's enough and returns whether it worked.NullPointerException.The program from the refresher crashes with NullPointerException.rename(book) משנה את השדה של הספר שקיבלה.rename(book) changes the field of the book it got.Book עם title, author, year, ומתודות String line() (Emma by Austen (1815)) ו-boolean isClassic() (לפני 1950).A class Book with title, author, year, and methods String line() (Emma by Austen (1815)) and boolean isClassic() (before 1950).TempLog עם מערך double[] values = new double[10], מונה int size, ומתודות add, max ו-average (רק על התאים שמולאו).A class TempLog with an array double[] values = new double[10], a counter int size, and methods add, max and average (over the filled cells only).Rect עם width, height ומתודות area(), perimeter(), isSquare() ו-Rect scaled(int k) שמחזירה מלבן חדש גדול פי k (המקורי לא משתנה).A class Rect with width, height and methods area(), perimeter(), isSquare() and Rect scaled(int k) returning a new rectangle k times bigger (the original doesn't change).class Book מתארת מה יש לכל ספר: שדות (title, pages) ומתודות (describe).class Book describes what every book has: fields (title, pages) and methods (describe).b = a מעתיק את החץ: שני המשתנים מצביעים על אותו ספר, ושינוי דרך b נראה דרך a.b = a copies the arrow: both variables point to the same book, and a change through b shows through a.null.A new array of objects is full of null.Cannot read field "title" because "b" is null:Cannot read field "title" because "b" is null:נבנה על ידיBuilt by Ariel Yohimovich