ArrayList need suggestions/opinion

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
User avatar
Bencratus
Posts: 51
Joined: Wed Jan 07, 2015 11:38 pm
Contact:

ArrayList need suggestions/opinion

Post 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
Last edited by Bencratus on Wed Feb 18, 2015 12:47 am, edited 1 time in total.
malyelfik
L2j Veteran
L2j Veteran
Posts: 355
Joined: Wed Sep 02, 2009 11:18 am
Location: Czech Republic

Re: ArrayList need suggestions/opinion

Post by malyelfik »

Try Arrays.asList()

Documentation: http://docs.oracle.com/javase/8/docs/ap ... l#asList-T...-
Image
User avatar
Bencratus
Posts: 51
Joined: Wed Jan 07, 2015 11:38 pm
Contact:

Re: ArrayList need suggestions/opinion

Post 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
User avatar
Zoey76
L2j Inner Circle
L2j Inner Circle
Posts: 7005
Joined: Tue Aug 11, 2009 3:36 am

Re: ArrayList need suggestions/opinion

Post by Zoey76 »

This is not from Java 8 :P
Powered by Eclipse 4.30 ๐ŸŒŒ | Eclipse Temurin 21 โ˜• | MariaDB 11.3.2 ๐Ÿ—ƒ๏ธ | L2J Server 2.6.3.0 - High Five ๐Ÿš€

๐Ÿ”— Join our Discord! ๐ŸŽฎ๐Ÿ’ฌ
Post Reply