In the task that returns a count of the same first and last names, the last name is the key, and the first name is the value in the HashMap. We can have duplicate values in the value field(first name) but the key values must be unique(last name). Therefore a count of the same values in the key field always fetches a 1, because duplicate values are not allowed in the key field. I don't understand why they have written a function to fetch a count of the same values for the last name which evidently is the key field.
Task only for the rich:
why doesn't it work like this in the removeItemFromMap function?
Map<String, Integer> copy = new HashMap<>(map);
for(Integer salary : copy.values()){
if (salary < 500){
map.remove(salary);
}
}
I'm not quite sure when to use Map.Entry and when to just use String/Integer in the iterator.
Task "We don't need repeats". "Create a Map<String, Integer> and add ten entries that represent (last name, first name)."
Its a Fault. Further in Requirements we see "The createMap() method must create and return a Map that has (String, String) elements and contains 10 entries."
I am really confused with every problem while passing the arguments and stuff. Why do they also not want use to print any text to the terminal is something that was actually bothering me. Anyways all exercises were confusing for me coz i felt that the problems can be solved using one or two methods itself but providing so many different methods made me confuse about the entire scenario.
the Hard tasks were really hard, but looked up a lot and learned a ton. I guess CG is trying to force us to learn like the programmers on the job? Even so, a little more instructions would've been better. Most difficulty was getting used to the multiple ways to iterate through the data structures and getting familiar with the details of the each methods. It was super helpful to read others' questions and those who commented/answered them. So, thanx everybody and happy coding! :)
For "We don't need repeats", pay close attention to what is required! You must remove ALL people with the same first names. My downfall was that I was trying to keep the first person and remove the remaining ones with the same name. Wasted a lot of time on this one. Hope this helps someone.
SinisaLevel 11, Banja Luka, Bosnia and Herzegovina
9 March 2021
Boy what a complication for those data structures in comparison to Python.
SinisaLevel 11, Banja Luka, Bosnia and Herzegovina
9 March 2021
The tasks are not so hard, but poorly explained. If the problem is unclear or badly explained you can't develop a solution to it. I find myself increasingly wasting time with confusion stemming from very bad task requirements, instead of thinking about the algorithms to actually solve the particular issues.
This website uses cookies to provide you with personalized service. By using this website, you agree to our use of cookies. If you require more details, please read our Terms and Policy.
GO TO FULL VERSION