Really? The compiler is not smarting to turn the first into the second? On Jun 23, 5:48 am, Dan Sherman <[email protected]> wrote: > As far as I'm aware (someone correct me if I'm wrong), primitive types have > no effect on garbage collection, especially local variables. > > A great example is: > List<Item> items; > for (Item i : items) { > // do something > > } > > When running will cause garbage collection, as each time that loop is > called, it allocates an Iterator<Item>. However the following would not. > > for (int i = 0; i < items.size(); i++) { > Item it = items.get(i); > > > > } > On Tue, Jun 22, 2010 at 5:31 PM, Neilz <[email protected]> wrote: > > To discuss this point further... > > > Does using Java primitive types still count in this scenario? Is it > > fine to create, for example, a number of int or boolean variables, > > within the game processing loop, or should these be created as static > > variables upon the class creation? > > > To demonstrate, is: > > > static int myVal; > > run(){ > > myVal = x * y * z; > > } > > > ...better than: > > > run(){ > > int myVal = x * y * z; > > } > > > Thanks. > > > On Jun 18, 8:37 pm, Dan Sherman <[email protected]> wrote: > > > Avoid allocations. > > > > Allocations = garbage collection. > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To post to this group, send email to [email protected] > > To unsubscribe from this group, send email to > > [email protected]<android-developers%2bunsubs[email protected]> > > For more options, visit this group at > >http://groups.google.com/group/android-developers?hl=en- Hide quoted text - > > - Show quoted text -
-- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

