This might seem a simple question, but I have been getting stuck on this little problem I have.
In java 7 you can iterate over your objects and set new values to its attribute.
for (int i = 0; i < continentLijst.size(); i++) {
continentLijst.get(i).setContinentId(i);
}
Now I'm searching to do the same in a Java 8 lambda. I thought something like:
int i =0;
continentLijst.stream().forEach(e -> {
e.setContinentId(i++);
});
Which obviously gives an error... As I said this might be a beginners mistake I'm making, but any help would be awesome!