অকল প্ৰদৰ্শন কৰা হৈছে
0:03
S… Speaker 2 (10- The Supplier Interface)
The supplier interface is the opposite of the consumer interface.
0:07
S… Speaker 2 (10- The Supplier Interface)
So instead of consuming a value,
0:09
S… Speaker 2 (10- The Supplier Interface)
it supplies a value.
0:10
S… Speaker 2 (10- The Supplier Interface)
So if you look at the documentation,
0:12
S… Speaker 2 (10- The Supplier Interface)
you can see here we have a single abstract method called get
0:16
S… Speaker 2 (10- The Supplier Interface)
which returns a value of type T.
0:18
S… Speaker 2 (10- The Supplier Interface)
So this interface is also a functional interface and we
0:23
S… Speaker 2 (10- The Supplier Interface)
can represent it using a lambda expression.
0:24
S… Speaker 2 (10- The Supplier Interface)
Let me show you.
0:25
S… Speaker 1 (10- The Supplier Interface)
So let's declare a supplier of double,
0:29
S… Speaker 2 (10- The Supplier Interface)
call it get random,
0:31
S… Speaker 2 (10- The Supplier Interface)
and set it to a lambda expression.
0:34
S… Speaker 2 (10- The Supplier Interface)
Now this lambda expression should match the signature of this method,
0:38
S… Speaker 2 (10- The Supplier Interface)
so it shouldn't have any parameters and it should return a value of type t,
0:42
S… Speaker 2 (10- The Supplier Interface)
in this case double.
0:43
S… Speaker 2 (10- The Supplier Interface)
So we type empty parenthesis because we don't have any parameters,
0:47
S… Speaker 2 (10- The Supplier Interface)
the lambda operator,
0:49
S… Speaker 2 (10- The Supplier Interface)
and then in the body of this lambda I'm going to return math .random
0:55
S… Speaker 2 (10- The Supplier Interface)
Now because we have a single statement and we're simply returning a value,
0:59
S… Speaker 2 (10- The Supplier Interface)
we can simplify this lambda expression.
1:01
S… Speaker 2 (10- The Supplier Interface)
That is why the return keyword is grayed out.
1:03
S… Speaker 2 (10- The Supplier Interface)
So we put the caret over here and press alt and enter to
1:08
S… Speaker 2 (10- The Supplier Interface)
replace this with a simpler lambda.
1:10
S… Speaker 1 (10- The Supplier Interface)
Take a look.
1:11
S… Speaker 2 (10- The Supplier Interface)
So empty parenthesis goes to math .random.
1:15
S… Speaker 2 (10- The Supplier Interface)
We don't need the curly braces,
1:17
S… Speaker 2 (10- The Supplier Interface)
we don't need the return keyword either.
1:19
S… Speaker 2 (10- The Supplier Interface)
Now, this lambda expression represents a function.
1:22
S… Speaker 2 (10- The Supplier Interface)
To call this function,
1:23
S… Speaker 2 (10- The Supplier Interface)
we should type get random dot get.
1:26
S… Speaker 2 (10- The Supplier Interface)
So this will return the random value,
1:30
S… Speaker 2 (10- The Supplier Interface)
and we can print it over here.
1:32
S… Speaker 1 (10- The Supplier Interface)
So every time we run this program,
1:36
S… Speaker 2 (10- The Supplier Interface)
we get a different value.
1:38
S… Speaker 1 (10- The Supplier Interface)
Now,
1:39
S… Speaker 2 (10- The Supplier Interface)
What you need to pay attention to here is that this function is not executed
1:43
S… Speaker 2 (10- The Supplier Interface)
until we explicitly call it.
1:46
S… Speaker 2 (10- The Supplier Interface)
This is called lazy evaluation.
1:48
S… Speaker 2 (10- The Supplier Interface)
So the value is not generated until we explicitly ask for
1:52
S… Speaker 1 (10- The Supplier Interface)
it.
1:52
S… Speaker 2 (10- The Supplier Interface)
Also, just like the consumer interface,
1:55
S… Speaker 2 (10- The Supplier Interface)
this supplier interface has a few specializations for working with
1:59
S… Speaker 2 (10- The Supplier Interface)
primitive values.
2:00
S… Speaker 2 (10- The Supplier Interface)
So we have double supplier,
2:02
S… Speaker 2 (10- The Supplier Interface)
we have int supplier,
2:04
S… Speaker 2 (10- The Supplier Interface)
we have long supplier and boolean supplier.
2:08
S… Speaker 2 (10- The Supplier Interface)
So if you're working with primitive values,
2:10
S… Speaker 2 (10- The Supplier Interface)
prefer to use this primitive specializations of the supplier interface because
2:15
S… Speaker 2 (10- The Supplier Interface)
you don't pay the cost of auto boxing the primitive value inside
2:19
S… Speaker 2 (10- The Supplier Interface)
a reference type and then
2:21
S… Speaker 2 (10- The Supplier Interface)
unboxing it later on.
2:22
S… Speaker 1 (10- The Supplier Interface)
So that's all about the supplier interface.
2:25
S… Speaker 2 (10- The Supplier Interface)
Next we're going to talk about the functional interface.

এই অনুলিপি AI (স্বয়ংক্ৰিয় কথোপকথন স্বীকৃতি) দ্বাৰা সৃষ্টি কৰা হৈছে। ইয়াৰ অন্তৰ্গত ত্ৰুটি থাকিব পাৰে - গুৰুত্বপূৰ্ণ ব্যৱহাৰৰ বাবে মূল অডিঅ'ৰ সৈতে পৰীক্ষা কৰক। AI নীতি

❤️ STT.ai ভাল পায়? আপোনাৰ বন্ধুসকলক কওক!
সাৰাংশ
এই ট্ৰান্সক্ৰিপ্টৰ AI সাৰাংশ সৃষ্টি কৰিবলৈ সাৰাংশ ক্লিক কৰক।
সাৰাংশ...
এই অনুলিপিৰ বিষয়ে AI ক প্ৰশ্ন কৰক
এই অনুবাদৰ বিষয়ে যিকোনো প্ৰশ্ন কৰক — AI-এ প্ৰযোজ্য অংশসমূহ বিচাৰি পাব আৰু উত্তৰ দিব।