מציג בלבד
0:03
S… Speaker 1 (3- Anonymous Inner Classes)
So in the last video we passed a new instance of our console printer
0:07
S… Speaker 1 (3- Anonymous Inner Classes)
class to a Greek method As I told you sometimes we don't want to explicitly
0:11
S… Speaker 1 (3- Anonymous Inner Classes)
create a class to implement an interface Perhaps we want to implement an
0:15
S… Speaker 1 (3- Anonymous Inner Classes)
interface only once and use it for a single purpose We don't want to reuse
0:19
S… Speaker 1 (3- Anonymous Inner Classes)
that class.
0:20
S… Speaker 1 (3- Anonymous Inner Classes)
So that's where we use anonymous inner classes So
0:25
S… Speaker 1 (3- Anonymous Inner Classes)
instead of creating a new instance of the console printer class here
0:29
S… Speaker 1 (3- Anonymous Inner Classes)
we can type new
0:31
S… Speaker 2 (3- Anonymous Inner Classes)
printer.
0:31
S… Speaker 1 (3- Anonymous Inner Classes)
So we type the name of the interface and press enter.
0:34
S… Speaker 1 (3- Anonymous Inner Classes)
What we have here is called an anonymous inner
0:38
S… Speaker 1 (3- Anonymous Inner Classes)
class.
0:39
S… Speaker 1 (3- Anonymous Inner Classes)
It's anonymous because this class doesn't have a name.
0:42
S… Speaker 1 (3- Anonymous Inner Classes)
It's just an implementation and we call it an inner class because we're
0:46
S… Speaker 1 (3- Anonymous Inner Classes)
using this inside a method.
0:48
S… Speaker 1 (3- Anonymous Inner Classes)
Okay, so in this class we're
0:52
S… Speaker 1 (3- Anonymous Inner Classes)
implementing the print method.
0:53
S… Speaker 1 (3- Anonymous Inner Classes)
Here we can use a print statement to print this
0:58
S… Speaker 1 (3- Anonymous Inner Classes)
message.
0:58
S… Speaker 1 (3- Anonymous Inner Classes)
Now when we run this program
1:02
S… Speaker 1 (3- Anonymous Inner Classes)
we get the exact same result.
1:03
S… Speaker 1 (3- Anonymous Inner Classes)
So this is how we can use an anonymous inner class.
1:07
S… Speaker 1 (3- Anonymous Inner Classes)
With anonymous inner classes,
1:09
S… Speaker 1 (3- Anonymous Inner Classes)
we can achieve the same result by writing less code.
1:12
S… Speaker 1 (3- Anonymous Inner Classes)
But Java 8 introduced a better and more concise way to achieve
1:16
S… Speaker 1 (3- Anonymous Inner Classes)
the same result.
1:17
S… Speaker 1 (3- Anonymous Inner Classes)
That's called a lambda expression and we're going to look at that next.

תעתיק זה נוצר על ידי AI (הכרה אוטומטית של דיבור). ייתכן שיש בו שגיאות אשר מאשרות את השמע המקורי לשימוש קריטי. מדיניות AI

❤️ אוהבים את STT.ai? ספרו לחברים שלכם!
תקציר
לחץ לסכם כדי ליצור סיכום AI של תעתיק זה.
מסכם...
שאל את אל על התעתיק הזה.
שאל כל דבר על התמליל הזה, הבינה המלאכותית תמצא חלקים רלוונטיים ותענה.