Java Fundamentals - Lesson 39 - Stream API Part 1

preview_player
Показать описание
Are you new to Java development? Do you want to know what to start with? This is a complete stream dedicated to you - the junior developer or future developer.

- Java OCP 11 certification
- Learn Java basics
- Find a junior java developer role

If your target is at least one of the above, then this lesson streaming is for you. Join!

Don't forget to follow me on Twitter @laurspilca or LinkedIn for more posts and discussions.

Рекомендации по теме
Комментарии
Автор

Man your content is so on point, every video you release contains too much details that are hard to find
anywhere else
!

dalichtioui
Автор

For the example at 41:30 some of you can just think of it as a for loop expression. for (int i = 0; i < arr.length; i++) the basic for loop or translated as: for(startCondition, endCondition, increment), which for streams is equivalent to --> Stream.iterate(startCondition, endCondition, increment)

nitestrikebg
Автор

Nice video sir

In interview, questions are asked based on flatmap and map.. please add program based on flatmap.+ Filter mix. In next video.

vivekguptacs
Автор

I think for the question it’s important to highlight that it’s lazy evaluation and that there isn’t any storage.

rydmerlin
Автор

What actually does a Stream store? How does it provides the values to be processed by intermediary methods?

adrianstefan
Автор

Hi Laurentiu, that static method <generate> is very interesting, because if there is no consumer nothing will be generated. I mean if line 20 is not existing program will not generate anything. From this perspective may we say that we could have a similar philosophy seen on flux and mono with <just> ?

dan
Автор

Hi LAurentiu,
question I see that I can use as many filters has I want...
but my question is can I put 2 or more conditions inside the filter?

i.e. .filter(x -> x!=2, x-> x!=4)

this gives me an error so I tried the below sample...


So that leads me to the following question...
if I wanted lets say numbers from 1 to 10, first 10 Random numbers ... but no 4 or 5,
I still want to display 10 ... if it is 4 or 5 I want it to re random until it comes up with 10 numbers no 4 or 5.

is there a method or I would first have to go through and evaluate that put it on a list then stream it out to lets say print...

Supplier<Integer> sup = () -> new Random().nextInt(10);
Stream<Integer> s3 = Stream.generate(sup); // they call this an infinite source
s3.limit(10)

.filter(x -> x!=2)
.filter(x -> x!=3)
.filter(x -> x!=4)
.filter(x -> x!=5)

.filter(x -> x!=8)
.filter(x -> x!=9)


peterfraga
Автор

Awesome video as always. I have a few question though.
If I have this code with the return is x++, why my program keep running but doesn't print anything?
Stream<Integer> sIterate2 = Stream.iterate(1, x -> x <= 100, x -> x++) // the x++
.filter(x -> x % 2 == 0);
󠀡󠀡
󠀡󠀡
Stream<Integer> sIterate2 = Stream.iterate(1, x -> x <= 100, x -> x + 1);
.filter(x -> x % 2 == 0); // Why I cannot continue using .forEach here?
<--- But I have to make it in separate line?

gg