I would always opt for the 2nd one when possible.. the variables live within
the scope of the method, so less chance of them hanging around in memory. I
forget if they live on the stack or not when declared/instantiated within
the method body as passed in parameters do. But having the method clean them
up for you at the end is better in my opinion than making them instance
variables of the class.

On Thu, Feb 11, 2010 at 11:44 PM, Sasikumar.S <sasikumar.it1...@gmail.com>wrote:

> Hi,,
>
>
> In my application i'm using more than 40 variables.
>
> when i try to execute my project it is taking more time than other
> projects.
>
> Which will make faster loading?..
>
> whether declaring in class or method ?.
>
> *example 1*
>
> Public class sample
> {
>
> private int s1;
> private int s2;
>
>
> public void sample_method()
> {
> }
>
> }
>
>
> *example 2:-*
>
> Public class sample
> {
>
> public void sample_method()
>
> {
>
> int s1;
>
> int s2;
>
> }
>
> }
>
>
> which one will be fast example 1or example 2 ?....
>
> Any one can tell this?...
>
> --
> Thanks & Regards
> Sasikumar.S
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to