I want to transform a list of String to a map, where the key of map is a simple increment.
For example:
List<String> result = new ArrayList<String>();
result.add("hello");
result.add("Java");
Pretend result:
Map<Integer, String> mapOfList;
map(1, "Hello");
map(2, "Java");
Try:
AtomicInteger atomic=new AtomicInteger(0);
mapOfList=result.stream().collect(atomic.incrementAndGet(), s -> s);