Fibonacci - exception
MartinMSPedersen opened this issue · comments
Martin Møller Skarbiniks Pedersen commented
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
Richard Warburton commented
See discussion on #27
Martin Møller Skarbiniks Pedersen commented
OK