KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a method that returns a Map. I would initially return the HashMap that the method generated, but thought it would be better to return an ImmutableMap. Unfortunately, the following statement refuses to work in eclipse: HashMap<File, File> map = new HashMap<File, File>(); map.put(...); . . . return ImmutableMap.builder ().putAll (map).build (); It keeps saying that I'm returning an incompatible statement, a Map<Object, Object> . I initially tried to use: return ImmutableMap<File, File>.builder ().putAll (map).build (); but that obviously didn't work. How would I best go about fixing this? Should I first store it in something like ImmutableMap<File, File> m = ImmutableMap.builder ().putAll (map).build (); or is there a more elegant solution?
Tags (comma-separated)
Save Edits
Cancel