Reputation: 879
Which is the better way to define multiple TextViews?
private TextView textView1;
private TextView textView2;
private TextView textView3;
or
private TextView textView1, textView2, textView3;
Upvotes: 0
Views: 86
Reputation: 4969
When compiler make the bytecode for your code then it sends to VM before sending the bytecode to the vm the progaurd(If you use or activate progaurd in your project) does shrink and optimize your bytecode whatever and how you write source code in your project. So I think which code writing style make you and your team more understandable that should be followed. Your both coding style is valid and standard.
Upvotes: 0
Reputation: 54
I would say use the second method because that would make the code mkre readable
private TextView mytextview1;
private TextView mytextview2;
private TextView mytextview3;
And as you in whatever way you write it dosent matter you can write the whole code in one line also but that dosent look good..
Upvotes: 0
Reputation: 754
What u really asking is how the variables in java can be declared.
ideally the Java compiler will do an optimization on your first option
private TextView mytextview1;
private TextView mytextview2;
private TextView mytextview3;
reduce it to second option, so inside the compiler both your options lead to same result. Furthermore since most of the TextViews will not be assigned again the compiler will make those variables final as well. Check this for further clarifications final variable optimizations
Upvotes: 2