Thursday, 8 August 2013

In Java, do ArrayLists that contain different types of objects use different amounts of memory?

In Java, do ArrayLists that contain different types of objects use
different amounts of memory?

For example, if you were to have
int a=2; int b=3;
ArrayList<Integer>integers=new ArrayList<Integer>();
integers.add(a); integers.add(b);
and
String c="cow"; String d="deer";
ArrayList<String> strings= new ArrayList();
strings.add(c); strings.add(d);
Would they take different amounts of memory? Any help/answer would be
highly appreciated, thanks!

No comments:

Post a Comment