I have implemented the following code using Java 8.
Map<String, String> coMap = getHashMap();
String newCoName = coMap.entrySet()
.stream()
.filter(coEntry -> coEntry.getValue().equals(newcoId))
.map(coEntry -> coEntry.getKey())
.collect(Collectors.joining());
String oldCoName = coMap.entrySet()
.stream()
.filter(coEntry -> coEntry.getValue().equals(oldcoId))
.map(coEntry -> coEntry.getKey())
.collect(Collectors.joining());
Now. I want to know any better way of doing this instead of repeating the same lines of code twice.
getCoName(String coId)