Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
Win a copy of Python Continuous Integration and Delivery this week in the Python forum!

praveen kumaar

Ranch Hand
+ Follow
since Apr 10, 2016
praveen likes ...
AngularJS Eclipse IDE Firefox Browser Java Spring VI Editor
I believe in karma, i love coding and love to write clean code. lifestyle -> simplicity is my best tool. history -> i have a academic gap in my studies(i had left from MAIT(CSE), ip university in 2013) but with a great determination i started again through IGNOU(in 2016, BCA). i love challenges in life, always ready to fight(mentally) in bad circumstances. present-> looking for opportunities...
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by praveen kumaar

Yan Digilov wrote:Ah, sorry yall, I am talking about the section ABOVE the sharpen your pencil piece.  I mean the one titled "Assignment".  It goes "Double d = x;" and there is an Integer and an int pointing to it...

I think taking a step to compile that simple line is not a big deal. Either it's an error or not, compiler is the best one which will tell you about it, it's one of the best core task assigned to it. but it's well likely for a compiler to not caught the errors which will really happen during run time as those are generated dynamically. in that case it's again not a following big step to run that program to be sure about the behaviour of code is, as i expected.
Now experiment the same code with a java as mentioned in the book and think about what really goes behind the scene?

Ask yourself:

1.) if not compiled, why really it didn't compile, what's wrong have you done there...
2.) if compiled but not ran, what's really something that compiler has not really caught. and the most important the error, why does it appear?
3.)if compiled and run successfully,  why can i assign int to a Double reference. what really is going behind the scene? Is there any optimization added by compiler, if so then what are they.

Tell us your views first, then we will see if their are any problems.
1 month ago

Rafael wrote:Do you know of any java project, preferably some application with social objective, where you can collaborate as a programmer on a voluntary basis?

Welcome to the Ranch, Rafael.
Hmmm social objective, can you be more specific as it's a relative term.what is your perspective ? Do you mean open source, their are many on GitHub, Go and explore them as per your requirement.

Note: The link i have attached contains a variety of projects which are both as large as JUnit and small as  a HelloWorld Example.

Hope it helps!

1 month ago
Congratulations! Mike.
1 month ago

Shubham Rai wrote:Intersection means common characters in all the given strings.

Shubham, it would be a lot better if you can post the original language in the problem. please don't forget to mention the source(for copyright issues). if it's from some book tell us the book name, page number etc. if you have a link to the original problem you have an option to cite the link also. We really want to help but we need to understand the problem first. As you can see in the previous discussion of this thread, i have guessed something and campbell has something else which is creating ambiguity.
And I think you should have a look at HowToAskQuestions.
1 month ago
List1.retainAll(List2.retainAll(List3)) -> I am sorry but it will fortunately fail as retainAll returns a boolean. it should have been
In plain english it means first retain only the elements in list1 which are present in list2 and then further again  retain olnly those elements in list1 that are present in list3. where list1, list2, list3 should be a List of Characters.
1 month ago

Campbell Ritchie wrote:What's an intersection character?

I mean characters common among all the String and if their is some character common among the input strings increment the count by 1 additionally if some counted character repeats in any string then it will be counted again if the same character repeats also in all other strings. That's a guess though. let the OP decide if it's what he wants.[Edited]
1 month ago

Campbell Ritchie wrote:Please explain exactly how you are counting letters. I can see c in all three Strings, so I would expect the answer 3.

I think he just needs the number of intersection characters of the n strings..
1 month ago
I think List1.retainAll(List2.retainAll(List3)) will do the job.

problem is on line 19, 27. you are not clearing the List before proceeding to the next iteration. and on line 27 you need to concatenate the characterss currently in List1 but you are simply assigning the character each time making s1 of length 1 containing the single character. Though your code needs refactoring and also their is much redundant code. why don't you use char[] instead of ArrayList...
1 month ago

Tim wrote:Not sure if it's strictly applicable, but I like the meme, anyway.

I think that meme is conveying more than the rest of the page there. and here also i think OP has got a wrong abstraction...
1 month ago
Well i think their is a design issue inherent in the problem. OP has declared a map as a parameter and what he wants is this map to retain the input order which i think is a strong precondition in terms of contract of a Map and thus failing Liskov Substitution principle. But i will like it to be reviewed by some staff members like Junilu, Campbell.
1 month ago

Carey Brown wrote:

How can you guarantee ordering for any map...
1 month ago

Tyoma Sakurakoji wrote:Are you need to preserve the original order of the input hashmap entries and just reverse it afterwards? If so, then remove sorted call and reverse the resulting list

Their is no such thing like order for HashMap as it is a unordered data structure, even HashSet is unordered and and streams also does not guarantee any ordering(Encounter order) for such objects. if you really want to preserve ordering LinkedHashMap preserves the same.
1 month ago
Unit Test
1 month ago
Version 2
1 month ago
Okay I think I should post the code here, I am posting them in different posts

Version 1
1 month ago