I have read that making something final and then using it in a loop will bring better performance, but is it good for everything? I have lots of places where there isnt a loop but I add final to the local variables. Does it make it slower or is it still good?
Also there are some places where I have a global variable final (e.g. android paint), does it mean I don’t have to make it a local final when using it in loops?
The first thing you should consider is; What is the simplest and clearest way I can write this code. Often this performs well.
finallocal variables is unlikely to affect performance much. They can help clarity when you have long methods, but I would suggest breaking up method is a better approach.finalfields can affect performance to small degree, but a better reason to make itfinalis to make it clear that this field never changes (which also helps the JIT)