aftabdear Posted September 4, 2017 Share Posted September 4, 2017 (edited) public static String[] axes = new String[] { "Iron axe", "Bronze axe", "Steel axe", "Mithril axe", "Adamant axe" }; I'm using the above, my question is when i use this to verify if my inventory contains the above items, why does it continue to execute when it only contains one of the items from the array I want it to execute when it contains all of those items not just one Edited September 4, 2017 by aftabdear Quote Link to comment Share on other sites More sharing options...
Lemons Posted September 4, 2017 Share Posted September 4, 2017 Because Inventory.contains only checks if it contains any of the given items, not all of the given items. You could try: Arrays.stream(axes).allMatch(i -> getInventory().contains(i)) This would make sure it contains all the items in your inventory, instead of just 1. 5 Quote Link to comment Share on other sites More sharing options...
The Undefeated Posted September 4, 2017 Share Posted September 4, 2017 (edited) getInventory().contains(item -> item.getName().contains("axe")); My bad, didn't read it correctly. Lemon posted the correct answer. Edited September 4, 2017 by The Undefeated Quote Link to comment Share on other sites More sharing options...