ສະແດງ​ແຕ່
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 ຂອງ​ບົດ​ບັນທຶກ​ນີ້.
ກຳລັງ​ສັງລວມ...
ຖາມ AI ກ່ຽວ​ກັບ​ການ​ແປ​ນີ້
ຖາມທຸກຢ່າງກ່ຽວກັບບົດບັນທຶກນີ້ - AI ຈະຊອກຫາສ່ວນທີ່ກ່ຽວຂ້ອງແລະຕອບ.