I recently read that you do not want to make new instances when unnecessary. I am not sure if I understand what it was saying. The problem was the repeat of this in LogCat:
08-09 17:12:11.300: D/dalvikvm(19620): GC_FOR_ALLOC freed 2281K, 23% free 9365K/12048K, paused 12ms, total 12ms
So is it better to have this method:
public int rand(int i) {
int rand = new Random().nextInt(i);
return rand;
}
than to have this method:
public int rand(int i) {
return new Random().nextInt(i);
}
if you are calling rand() a lot? Why or why not? Thanks for helping the newb!