Hi Everyone.

I'm just wondering if using generics in a class's definition is a good idea
in Android. What I'm inclined to do is define some class that stores and
operates on some numeric types.  I want to be able to instantiate an
integer, long, float, or double version of this class.  So I want the
int'ified version of this object to only store an int, instead of casting
the ints from the constructor to a long; and same thing for float/double
too. This way I minimize the amount of allocated space per number. So anyway
this is perfectly achievable with generics... but I always get nervous
thinking about generics and numeric types since every time I pass an int
argument to a method that takes a Number as an argument, it'll be turned
into an Integer, and then that Integer will have to be cleaned up later.

So is it a good idea to use generics for primitive numeric types in Android
or will it cause ugly unnecessary garbage collection?

Thanks, Rob

-- 
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

Reply via email to