Atul More

Ranch Hand
+ Follow
since Dec 26, 2016
Atul likes ...
Java jQuery Spring
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
11
Received in last 30 days
0
Total given
6
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Atul More

1. While making update to version, make sure you have version present in the Maven repository.
2. Also make sure while making the changes to the certain module, make sure other modules which are used by this module or by application also get updated or compatible with it.(This is my personal observation, kind of problem I have also faced)
2 weeks ago
As the spring boot followed the new servlet specifications, where we don't need to define web.xml file.
You can configure all these things which you mentioned(in web.xml) through java files as well.
2 weeks ago
Hello Campbell,

Its atomic, sorry its my mistake.
Atomic is mainly working on the principal of CAS (Compare And Swap).
By using the Read and Write lock mechanism, the only thing I want to understand is, how DB operation we manage like account debit/credit. Multiple threads reading the value and writing as well.

Thanks,
Atul
Hi,

It is basic question but I am not yet work on kind of functionalities. So asking this question.
Can I use "automic" variable in "ReadWriteLock" mechanism? Is it right ?

Thanks,
Atul

3 weeks ago
Hi,

A code I finished one task where I need to find a maximum sentence from a given sentece.
The scenario is like, let say you have a sentence: I am Atul More. I am a Java developer.
So again divide the sentence on to the basis of full stop(.). So they are two different sentence I am Atul More and I am a Java developer.
After that I need to find out the max length string from them. So the answer is: 5 for I am a Java developer.

The code is dine but have a couple of questions:
1. Is the approach is right?
2. Can I make it reduce the code by merging two line os code or something.

The code is as below:


Thanks,
Atul
3 weeks ago
Hi,

I am able to solve the issue. Now getting the desired result.




Thanks,
Atul
1 month ago
Hi,

Thanks Camplbell.

Well done


Am I deserving a cow in that case ... 
(Kidding  )

You might consider line 8 as ....collect(Collectors.toList())


Yes ... Thats also work.

Thanks,
Atul
1 month ago
Hi Campbell,

Thanks for your inputs and help. The required solution is as below:



Now it is returning me the expected result: {4, 9, 6}

Thanks,
Atul
1 month ago
Hi,

Line no.2 returning me

java.util.stream.ReferencePipeline$Head@3d075dc0
java.util.stream.ReferencePipeline$Head@214c265e
java.util.stream.ReferencePipeline$Head@448139f0



Just need help how can I process each one.
Integer or Long does not matter but need some help to do it.

Thanks,
Atul
1 month ago
Hi

If I use map then it return me soemthing like:


java.util.stream.ReferencePipeline$Head@3d075dc0
java.util.stream.ReferencePipeline$Head@214c265e
java.util.stream.ReferencePipeline$Head@448139f0



1 month ago
Hi,

Yes, but how can I return a List<Long> from the stream. I using "reduce" to calculate the strength.
This is the function:


How can I change it so it gives me the List<Long> instead of long value.

Thanks,
Atul
1 month ago
Hi,

Ok, let me explain what exactly I am looking for.

I am passing 2 parameters to "calculateSentece" function, one is the dataMap which contains the "word" as key and a "number" as a value. The second parameter is the list of sentences.
I want to calculate strength of each sentence.
For that:
1. I am iterating a list
2. take each sentence
3. Split it with the space
4. After split I got array of words of sentence
5. For each word I have associated number in the "dataMap"
6. Taking that number of each word
7. Multiplying it

From the code example, I am passing 3 sentences to function: "tabs is bats", "act the cat", "cat is aabc"
Lets take first sentence: "tabs is bats" -> tabs has value 2, is has value 1, bats has value 2.
So the calculations is: 2*1*2 = 4
Same for "act the cat": 3*1*3 = 9, "cat is aabc": 3*1*2 = 6.

So the final output is: {4, 9, 6}

I want to process each sentence and calculate its strength and store it in the list and once all done return the list of that strength.

Right now the function which I am using is calculating the strength of all sentences in one go.
Want ti write a function which calculate the strength of each sentence and store it in list and once all done return the list of strength.

I was trying to write the function but not able to succeed. Just able to calculate the strength of all sentence, not for individual sentence.

Hope this will help to understand what I am looking for.

Thanks,
Atul
1 month ago
Hi,

The current function returning long only but I want to return a "List<Long>" .
I am passing a "List<String>" which contains sentences.
For each sentence I want to calculate a value and at the end return the list of calclated values into a list.

Thanks,
Atul

1 month ago
Hi,

Yes, but you cannot use the same Stream twice; you may need to create two Streams.



Understood. I have to create each stream for each loop.
But how can I do that?
How to write that particular code.

Thanks,
Atul
1 month ago
Hi,

I want to get the multiplication of values and store it into a list.
The code is below:



The output of above program is: 216
But I am looking for answer id : {4, 9, 6}
It is like: tabs=2 * is=1 * bats=2 
              2 * 1 * 2 = 4

Same for other sentences.

Right now I am returning the multiplication of all but I want to get the multiplication of each sentence which I am passing in list.

I am able to write the code up to certain thing but not able to get the desire result.

Looking for some hint, how can I do that.

Any help on this.

Thanks,
Atul
1 month ago