Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SuppressWarnings("unchecked")
- public static boolean containsNegative(BagInterface<Integer> bag) {
- BagInterface<Integer> tempBag = new ArrayBag<Integer>();
- boolean status = false;
- while(!bag.isEmpty()) {
- int hold = bag.remove();
- if(hold < 0)
- status = true;
- tempBag.add(hold);
- }
- while(!tempBag.isEmpty()) {
- bag.add(tempBag.remove());
- }
- return status;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement