Created
April 16, 2017 13:33
-
-
Save john77eipe/999a05e53b9d8d54930dced19198234e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//client creates list of Ints | |
List<Integer> listOfInts = new ArrayList<Integer>(); | |
listOfInts.add(2); | |
listOfInts.add(3); | |
listOfInts.add(4); | |
//client does the filtering based on his logic | |
//let's say he wants to filter out even numbers | |
Iterator<Integer> itr = listOfInts.iterator(); | |
while (itr.hasNext()) { | |
Integer i = itr.next(); | |
if(i%2==0) | |
itr.remove(); | |
} | |
//Client calls Vendor provided function | |
int result = MathUtility.sum(listOfInts); | |
//In the provided Vendor's MathUtility class | |
class MathUtility { | |
public static int sum(List<Integer> list){ | |
//ability to add is only here | |
int sum=0; | |
for(Integer i: list){ | |
sum=sum+i; | |
} | |
return sum; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment