+ 8

Does the addAll() differ from add()?

while adding elements to a list(an ArrayList), sometimes adding an element brings up the all phrase I didn't type, so I end up removing it, for example. in this; ArrayList<Integer> primes = new ArrayList<Integer> (); when it comes to adding elements; primes.add(3); but as I open the parenthesis, something like auto correct occurs and this comes up: primes.addAll(3); I'm always inclined to delete off the "All". does this "All" have an implication? thanks?

16th Aug 2018, 5:47 PM
Mark 🇺🇬 [INACTIVE]
Mark 🇺🇬 [INACTIVE] - avatar
3 Antworten
+ 4
You can use .addAll to add another whole List to your ArrayList; .add is only for single elements.
16th Aug 2018, 6:13 PM
Schindlabua
Schindlabua - avatar
+ 5
Schindlabua oookay. thanks very much
16th Aug 2018, 7:04 PM
Mark 🇺🇬 [INACTIVE]
Mark 🇺🇬 [INACTIVE] - avatar
+ 2
mark am in uganda too gv me yo contact so that we can connect
24th Aug 2018, 6:15 AM
Andrew
Andrew - avatar