Page 1 of 1

ArrayList need suggestions/opinion

Posted: Wed Feb 18, 2015 12:12 am
by Bencratus
Hello,

I hate when need write:

Code: Select all

buffs.add(1045);
buffs.add(1048);
buffs.add(1040); 
what you think about this method to add all ArrayList? Or you have any other suggestions?
I'm smart badass :mrgreen: :mrgreen: :roll: 8) :shock:

Code: Select all

		int x[] = {1045,1048,1040};
		for (int a = 0; a < 3; a++)
		{
			buffs.add(x[a]);
		}
malyelfik wrote:Try Arrays.asList()

Documentation: http://docs.oracle.com/javase/8/docs/ap ... l#asList-T...-
Better way and it works, thanks to malyelfik and thanks to java 8 :D

Thanks,
Bencratus

Re: ArrayList need suggestions/opinion

Posted: Wed Feb 18, 2015 12:32 am
by malyelfik
Try Arrays.asList()

Documentation: http://docs.oracle.com/javase/8/docs/ap ... l#asList-T...-

Re: ArrayList need suggestions/opinion

Posted: Wed Feb 18, 2015 12:43 am
by Bencratus
malyelfik wrote:Try Arrays.asList()

Documentation: http://docs.oracle.com/javase/8/docs/ap ... l#asList-T...-

Code: Select all

		List<Integer> e = Arrays.asList(1045,1048,1040);
		buffs.addAll(e);
Yeah working, thanks a lot man, that's why I love java 8;D

Re: ArrayList need suggestions/opinion

Posted: Wed Feb 18, 2015 2:32 am
by Zoey76
This is not from Java 8 :P