is there any pattern for count, size, length and their return type?
maybe all new api return long from count?
About Question enthuware.ocpjp.ii.v11.2.1882 :
Moderator: admin
-
- Posts: 62
- Joined: Fri Aug 07, 2015 2:16 pm
- Contact:
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.ii.v11.2.1882 :
Generally, size and length are int and count and sum are in long. But you should not rely on it because there is no documented rule. You might see a method that doesn't follow it.
If you like our products and services, please help us by posting your review here.
-
- Posts: 3
- Joined: Fri Sep 20, 2019 11:53 am
- Contact:
Re: About Question enthuware.ocpjp.ii.v11.2.1882 :
count is always long/Long.
In IntStream, LongStream, DoubleStream
long count()
In Collectors
Long counting()
size() in List is 'int', length in array and string is also 'int'. However, these two are too fundamental, I think it's unlikely to trick you with them in OCPJP.
In IntStream, LongStream, DoubleStream
long count()
In Collectors
Long counting()
size() in List is 'int', length in array and string is also 'int'. However, these two are too fundamental, I think it's unlikely to trick you with them in OCPJP.
-
- Posts: 4
- Joined: Wed Jun 05, 2019 3:22 pm
- Contact:
Re: About Question enthuware.ocpjp.ii.v11.2.1882 :
With regards to sum:
- IntStream sum() returns int
- DoubleStream sum() returns double
- LongStream sum() returns long
Who is online
Users browsing this forum: No registered users and 76 guests