The final modifier does not make a variable a constant; it merely makes a constant reference to the variable. In the case of primitives, if the link becomes a constant, then the variable is also (not your case), in cases with objects, this means that the variable cannot be changed to another, but the parameters of the current can be changed.
The problem is not in the final modifier, but in the lack of understanding of its essence, but since you didn’t describe what it means достучаться , it’s hard to guess what the real problem is - is the compiler cursing or the error is in progress? Everywhere you fullDrivers.size() on fullDrivers.size() , especially in the cycle, although it would be more correct to rely on finalMarker.length , suddenly you have changed the size of fullDrivers.size() and you climb out of the array for the period before the execution in the main thread? runOnUiThread does not guarantee instant execution in the main thread, it just puts your block of code in the queue for execution in the main thread.
I can offer a variant of writing code without the final modifier for an array of markers:
final Handler handler = new Handler(); Runnable runnable = new Runnable() { @Override public void run() { Marker[] marker = new Marker[fullDrivers.size()]; for (int i = 0; i < marker.length; i++) { if (marker[i] != null) { marker[i].setPosition( transfomation(fullDrivers.get(i).getLatlng()) ); } marker[i] = mMap.addMarker( new MarkerOptions() .position(transfomation(fullDrivers.get(i).getLatlng())) ); } handler.postDelayed(this, 6000); } }; runnable.run();
And when you need to stop the execution of the repeat method:
handler.removeCallbacks(runnable);