RichardWarburton / java-8-lambdas-exercises

Exercises and Answers for Java 8 Lambdas book

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fibonacci - exception

MartinMSPedersen opened this issue · comments

This code in chapter 5 is not correct:
public long fibonacci(int x) { return cache.computeIfAbsent(x, n -> fibonacci(n-1) + fibonacci(n-2)); }
because you are not allowed to change the cache when you are using computeIfAbsent()

Exception in thread "main" java.util.ConcurrentModificationException

See discussion on #27