Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution for Reversing a Map in Java #196

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

GKKB
Copy link

@GKKB GKKB commented Oct 5, 2018

No description provided.

@pmavinkurve-mdsol
Copy link

pmavinkurve-mdsol commented Nov 2, 2018

Hi @GKKB - thanks for the solution. I checked through the imperative section and it looks good! But i am not familiar with the declarative style. I put this code in an online Java compiler and it gives an error with JDK 9. I get the same error locally on my mac, but i thought it could be because i am running Java 1.8

These are the compiler errors:

        inputMap.forEach((key,value) -> outputMap.merge(value, List.of(key), ReverseAMap::mergeListsOfValues));
                                                                   ^
  symbol:   method of(String)
  location: interface List
/ReverseAMap.java:66: error: cannot find symbol
        Map<String,String> map = Map.of("a","1", "b","2", "c", "1", "d", "3", "as", "3");   // Java 9
                                    ^
  symbol:   method of(String,String,String,String,String,String,String,String,String,String)
  location: interface Map
2 errors

I used https://www.jdoodle.com/online-java-compiler
Could you look into the errors when you get a chance?
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants