Suhaas Parekh

Greenhorn
+ Follow
since Jun 11, 2020
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
2
Received in last 30 days
2
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Suhaas Parekh

I am trying to create an identical singly linked list, but it is not working.

5 days ago
My question is on below code.

1. Does the raw type linked list accept primitives or they automatically converted to wrapper class objects?
2. How come the equality check and equals method both are returning true?
3. How do I print all the values in the linked list?

5 days ago
My question is on below code.

The linked list object in the below code should print an address or reference, but it is printing an empty list. Why?

5 days ago
Hi ,

My question is on below code. Why does printing 1/2 floors the value to 0 while printing -1/2 ceils the value to 0.


Output:
0
0

6 days ago
Hi All,

My question is on below code. My input is three lists:[-1,-1,2],[-1,-1,2],[-1, 0, 1].  I want the output without duplicates and as below.

Expected output: [[-1,-1,2],[-1, 0, 1]]]

Actual output: [[-1, 2], [-1, 2], [-1, 0, 1]]

1 week ago
Hello Friends,

I am looking to convert the following code and write it using IntStream. Below is the code and expected output.

Output:
1
22
333
4444
55555

1 week ago
Is System.out.println not a terminal operation in the above code?
1 week ago
Hi All,

1. What is the use of mapToObj in below code?
2. Is mapToObj used to convert primitive stream to wrapper class stream?
3. In general, is there anything useful that can be done by mapToObj?


1 week ago
Hi All,

Why my statement in line 11 is not printing any output, while statement in line 15 is able to print the output?

1 week ago
Hi All,

My question is on the below code. I am trying 2 different ways to generate random numbers from 0 to 10.

1. Why is the 2nd one generating numbers greater than 10 although I have passed the seed as 10 to the constructor of Random?

1 week ago
My question is on below code.

1. Which method is returning optional in below code, line no 12? Which is the last method to execute in this line no 12? Will the return type of the last method to be called be the return type of the whole statement in the same line?

1 week ago
What is the difference between Stream<Integer> and Intstream?
1 week ago
Ok thanks.

I have different question on the below code.

In the below code we are comparing 2 elements of the list at a time, but it is actually sorting all the elements in the list. So how does the sorting happen internally?

1 week ago
Ok, but how is it able to infer the type(in the below code, line 16) when I dont use reversed()? Also I want to know on what basis will the compiler be able or not able to infer the type?


Output:
$javac HelloWorld.java
$java -Xmx128M -Xms16M HelloWorld
[Person[name=aaa],age=[10], hobbies=[[Cricket, Tennis]], Person[name=ccc],age=[14], hobbies=[[Walking, Tennis, Cricket]], Person[name=bbb],age=[12], hobbies=[[Cricket, Walking]]]
Sort by  number of hobbies[Person[name=aaa],age=[10], hobbies=[[Cricket, Tennis]], Person[name=bbb],age=[12], hobbies=[[Cricket, Walking]], Person[name=ccc],age=[14], hobbies=[[Walking, Tennis, Cricket]]]


1 week ago
Ok, I modified the code as below and it is working fine, but I have the following questions.

1. In the first statement i->i.intValue() returns a int so the mapToInt returns IntStream which makes sense, but in statement 2 & 3 the part inside mapToInt returns an Integer object. So how is it converted to IntStream which is actually a stream of int primitives?

2. Does stream work with int primitives? Can I write something like Stream<int>?

1 week ago