Reputation: 5183
I was reading the source code of TextView and I met this code snippet:
RectF mTmpRectF = new RectF();
float[] mTmpOffset = new float[2];
ExtractedTextRequest mExtracting;
final ExtractedText mTmpExtracted = new ExtractedText();
So, there they define mTmpExtracted as final, but not mTmpRectF.
I have read this What does "final" do if you place it before a variable? where there is analyzed when to use final.
Thus since both objects (mTmpRectF & mTmpExtracted) could be final in this specific case, is there any other reason (i.e. performace, etc) that only one is set to final or it is just a developer code-style?
Thanks!
Upvotes: 7
Views: 15726
Reputation: 76496
I would say the extractedText has been set to final so it cannot be modified after it has been extracted, where as the coder is not bothered if the rectangle get's modified.
Upvotes: 7