- #1
kirkulator
- 33
- 0
I am learning about the ArrayList class in my java programming II class.
I am wondering why you would specify an arrayList to only contain, for example, strings:
ArrayList <String> arrayName = new ArrayList <String> ();
versus
ArrayList arrayName = new ArrayList ();
in which, to my knowledge you can use ANY object type you please or even, different types of objects
Why would someone use the prior?
Also, the default capacity of an ArrayList is 10. Meaning that is its size before expansion or contraction...why would anyone have a reason to change this capacity if you can just add or remove elements to the size you want?
Thanks so much, my professor seemed to "not understand" my question (foreign folk)
:p
Amanda
I am wondering why you would specify an arrayList to only contain, for example, strings:
ArrayList <String> arrayName = new ArrayList <String> ();
versus
ArrayList arrayName = new ArrayList ();
in which, to my knowledge you can use ANY object type you please or even, different types of objects
Why would someone use the prior?
Also, the default capacity of an ArrayList is 10. Meaning that is its size before expansion or contraction...why would anyone have a reason to change this capacity if you can just add or remove elements to the size you want?
Thanks so much, my professor seemed to "not understand" my question (foreign folk)
:p
Amanda