Я знаю, что внутри лямбды не может быть финальной / эффективной финальной переменной.Если это произойдет, возможно, вы работаете над устаревшей версией объекта.Я полагал, что компилятор не жаловался на этот код, где параметр функции может быть не окончательным:
Обновление сообщения с полным кодом:
public static void main(String[] args) {
Object x=new Object();
x=new Object();// I can reassign x as much as I can
test(x);
}
public static void test(Object x) {
// I can't reassign x here, shouldn't it disallow me to use function parameter ?
List<String> list=new ArrayList<>();
list.forEach(entry->System.out.println(entry+x)); // x here could be not final why the compiler didn't complain ?
}