Swapna latha

Ranch Hand
+ Follow
since Dec 18, 2011
Swapna likes ...
jQuery Eclipse IDE
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
7
Received in last 30 days
0
Total given
49
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Swapna latha

Hi All,

I am really confused in applying lambda map function where as the code which i am reading has got the result.



What i am doing wrong ? Please guide me .

Thanks & Regards,

Swapna.
10 months ago
Hi, I am working on few examples on Threads and i do see that Thread class has an Functional interface inside it.

I have seen an example in an udemy course like:



Could any one please exaplain the advantage of functional interface in a class.

Stephan van Hulst wrote:On a tangent: In general you don't need to worry about the A parameter. You only need to care about it if you implement your own Collector.


Thank you Stephan.
Thank you very much Tim. I got the answer now.

Tim Holloway wrote:Try this with 1:59 instead of 2:00. You might find it interesting. Indeed, try 1:59:59

Campbell Ritchie wrote:But Comparator is a functional interface.


Got it Campbell. Thank you very much.
But I have used BiFunction above. Comparator is not a Bifunction right.

Campbell Ritchie wrote:But Comparator is a functional interface.

Campbell Ritchie wrote:Have you seen the documentation for Collections#sort()?


Yes Campbell, it takes the second argument as Comparator but not function. So confused at this part.

Thanks & Regards,

Swapna

Stephan van Hulst wrote:You need to tell us what part of the explanation is not clear to you, and explain to us why you think it is 0.



Stephan, the lines of codes are as follows with my explanation . Correct me if i am wrong

LocalDateTime ld1 = LocalDateTime.of(2015, Month.NOVEMBER, 1, 2, 0); // This line of code is having a time of 2 AM so as per DST savings, it should become 1 AM
ZonedDateTime zd1 = ZonedDateTime.of(ld1, ZoneId.of("US/Eastern"));
LocalDateTime ld2 = LocalDateTime.of(2015, Month.NOVEMBER, 1, 1, 0);// There wont be any change of time as the time is still 1 AM and time changes after 2 AM
ZonedDateTime zd2 = ZonedDateTime.of(ld2, ZoneId.of("US/Eastern"));// As both the times are 1 AM , the result is zero.

Thanks & Regards,

Swapna.
Hi All,

I am practising questions from both enthuware and whizlab and i have got struck in understanding how does sort method takes function as 2nd argument.



Question is how function as 2nd argument to sort method.

Thanks & Regards,

Swapna.

Stephan van Hulst wrote:What part don't you understand?


Stephan, I am not sure how the answer is -2. I still think answer is 0. The explanation given by enthuware is not clear to me.


Thanks & Regards,

Swapna.
I am practising enthuware questions and i got confused in one of the question and is as follows:



The options are :
1
-1
0
2
-2
This will not compile.

When i have chosen it as 0 , but i see that that answer from enthuware is -2.

Explanation by enthuware software guys is as follows:


Think of it as follows -
The time difference between two dates is simply the amount of time you need to go from date 1 to date 2.
So if you want to go from 1AM to 2AM, how many hours do you need? On a regular day, you need 1 hour. That is, if you add 1 hour to 1AM, you will get 2AM. However, as given in the problem statement, at the time of DST change, 2 AM becomes 1AM. That means, even after adding 1 hour to 1AM, you are not at 2AM. You have to add another hour to get to 2 AM. In total, therefore, you have to add 2 hours to 1AM to get to 2AM.

The answer can therefore be short listed to 2 or -2. Now, as per the JavaDoc description of the between method, it returns negative value if the end is before the start. In the given code, our end date is 1AM, while the start date is 2AM. This means, the answer is -2.



I am not clear about the explanation of Enthuware guys

Thanks

Swapna
Hi All,

I am practising OCP questions by Enthuware and the code is as follows:



Can we reuse the stream as i used stream once with dList and also the second time.

Thanks & Regards,

Swapna
1 & 2. But Enthuware has shown that 3rd is also correct answer. Not sure how 3rd is correct answer and even i have doubt why 1 and 2 are also correct.

Stephan van Hulst wrote:Which answer do you think, and why?

Hi All,

As i am practising the enthuware for OCP in JDK 1.8, i have encountered a quuestion which has three options as answers. I have not understood why those three are correct, especially the third option. Please find the code below:



Thanks

Swapna.