3- Anonymous Inner Classes
Jun 26, 2026 22:49
· 1:23
· English
· Whisper Turbo
· 2 གསལ་བཤད་
ཡིག་ཆ་འདི་ཕྱི་ཚེས་ ༡༥ ཉིན་མཇུག་བསྡུ་ནི་ཨིན་མས།
གནས་བརྟན་གྱི་གནས་བཞག་གོང་འཕེལ་བཏང། →
སྟོན་རྐྱངམ་ཅིག་
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 བཅུད་བསྡུ་ཐོན་ནི་གི་དོན་ལས་ བཅུད་བསྡུ་ ཟེར་བའི་བསྒང་འདི་བསྒང་བསྒ
དྲན་ཐོ་བསྡུ་གསོག...
དྲན་ཤེས་ལ་དྲི་བ་དྲིས་ལན་ཞུ།
ཡིག་ཆ་འདི་གི་སྐོར་ལ་དྲི་བ་ཅི་རིགས་ཞུས་ནའང་ བཅོས་མའི་བློ་རིག་གིས་ འབྲེལ་བ་ཡོད་པའི་དོན་ཚན་ཚུ་ འཚོལ་ཞིབ་ དང་ལན་འདེབས་ འབད་འོང་།