Hello,
e.g. character have these buffs in arraylist which will be added if he press button x,a,b etc.
List <Integer> _buffs = new ArrayList<>();
_buffs.add(100);
_buffs.add(101);
_buffs.add(102);
how to check how much he have buffs which ids are 101 and 102?
because if _buffs.size(); it will returns all hes buffs count, but I need only e.g. 101 and 102.
also _buffs.contains don't need for me, because it is boolean, I need int...
Thanks,
Bencratus
ArrayList to check
Forum rules
READ NOW: L2j Forums Rules of Conduct
READ NOW: L2j Forums Rules of Conduct
- Bencratus
- Posts: 51
- Joined: Wed Jan 07, 2015 11:38 pm
- Contact:
- Zealar
- L2j Veteran
- Posts: 1236
- Joined: Sun Jul 15, 2007 10:29 am
Re: ArrayList to check
Replace list with map
-
- L2j Veteran
- Posts: 855
- Joined: Mon May 03, 2010 8:38 am
- Location: France
Re: ArrayList to check
Difficult to know what you are really doing so I'm just going to give you what you wanted
long buffCount = _buffs.stream().filter(b -> (b == 101 || b == 102)).count();
long buffCount = _buffs.stream().filter(b -> (b == 101 || b == 102)).count();
- Bencratus
- Posts: 51
- Joined: Wed Jan 07, 2015 11:38 pm
- Contact:
Re: ArrayList to check
Thanks, helpedZealar wrote:Replace list with map
Thanks, but your method for me hardcoded if I want to use more buffs not only these 2Sdw wrote:Difficult to know what you are really doing so I'm just going to give you what you wanted
long buffCount = _buffs.stream().filter(b -> (b == 101 || b == 102)).count();