Technically, it could print an Optional containing any name from the list.If you had just this :
Optional<String> ops = names.stream().parallel().findAny();
It could potentially print any name from the list because of .parallel().
About Question enthuware.ocpjp.v8.2.1869 :
Moderator: admin
-
- Posts: 54
- Joined: Thu Mar 03, 2016 1:26 pm
- Contact:
About Question enthuware.ocpjp.v8.2.1869 :
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1869 :
Well, from that perspective it should say, it could potentially print an Optional containing a String containing chars for any name from the list
Since it is making a general statement about the code snippet whose last line is System.out.println(ops);, I think it is ok to say that it prints name. The fact that it prints an Optional is quite clear because we are indeed passing an Optional to println.
HTH,
Paul.
Since it is making a general statement about the code snippet whose last line is System.out.println(ops);, I think it is ok to say that it prints name. The fact that it prints an Optional is quite clear because we are indeed passing an Optional to println.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 125
- Joined: Thu Jul 05, 2018 6:44 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1869 :
Hi Admin
My understanding is that it could potentially print any name from the list because of findAny. I.e. whether parallel is used or not, the behaviour is the same.
Thanks.
If you had just this :It could potentially print any name from the list because of .parallel().Code: Select all
Optional<String> ops = names.stream().parallel().findAny();
My understanding is that it could potentially print any name from the list because of findAny. I.e. whether parallel is used or not, the behaviour is the same.
Thanks.
-
- Posts: 85
- Joined: Mon Dec 24, 2018 6:24 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1869 :
Just want to confirm one thing: we can't chain any terminal operation after another terminal operation, right? so, there is only one terminal operation is allowed in the stream.
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1869 :
Yes and you should also understand the reason why.
If you like our products and services, please help us by posting your review here.
-
- Posts: 85
- Joined: Mon Dec 24, 2018 6:24 pm
- Contact:
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1869 :
Correct.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: Bing [Bot] and 55 guests