There is the following code:
String[] prop_run; prop_run[0] = "classA"; prop_run[1] = "classB"; for (int i = 0; i <= prop_run.length; i++) { new Thread(() -> RunClassByName(prop_run[i])).start(); } private static void RunClassByName(String class_name) { //... } return; Result:
Exception in thread "main" java.lang.Error: Unresolved compilation problem: Local variable i defined in an enclosing scope must be final or effectively final at Main.main(Main.java:24) On the 24th line, the following is written: new Thread(() -> myFunction(prop_run[i])).start();
How to fix the problem?