|
Your constructor should look like this:code:
Also you do not need the @Autowired annotation for constructor injection.
|
# ¿ Sep 8, 2020 23:27 |
|
|
# ¿ May 21, 2024 00:42 |
|
Jabor posted:I do most of my coding over remote desktop and it's fine, lol My flatmate has his remote desktop on Azure and it works surprisingly well. The low refresh rate obviously sucks, but there is very little perceivable latency when typing.
|
# ¿ Feb 13, 2021 10:38 |
|
The loop you are trying to replace here is either complete garbage or intentionally confusing. Try to think about what that loop is actually doing and look on the official documentation for java streams which methods you need. Also think about why they are iterating over document instead of the entries in wordFrequency.
|
# ¿ Nov 28, 2022 01:01 |
|
You need to look at the API of maps before you just guess code. Your IDE already tells you that you cannot stream maps. It should also tell you all methods that maps provide. If you are just using a text editor for some reason you need to look at the official documentation here https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/util/Map.html You really need to learn how to use documentation to see what is actually possible before writing code. Also what are you filtering? And what are you using that map for?
|
# ¿ Nov 28, 2022 20:16 |
|
That's more like it. You could look it up on stack overflow, but you need to do .max(Comparator.naturalOrder()) for it to work. If you only need to know how often the most common word appears you are now done. If you want to also know what the most common word is, you need to use a different Comparator and you cannot use wordFrequency.values(), since that only contains the frequency of words and not the word itself. Even if you don't have to do it for your homework, you should try to do it by yourself by looking at the Comparator and Map documentation.
|
# ¿ Nov 28, 2022 21:11 |
|
You did the exact thing you want to do a couple of posts earlier.
|
# ¿ Nov 28, 2022 23:34 |
|
Remove the parenthesis before k.getValue()
|
# ¿ Nov 29, 2022 22:50 |
|
|
# ¿ May 21, 2024 00:42 |
|
The only thing i would change is your sort method. You can do better using the built in Comparator functions. See: https://www.baeldung.com/java-8-comparator-comparing Refactoring other stuff there would just make it more complicated for marginally less repetition.
|
# ¿ Mar 1, 2023 00:02 |