Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. import java.util.ArrayList;
  2.  
  3. public class WordPairList {
  4.  
  5. private ArrayList<WordPair> allPairs;
  6. //https://pastebin.com/KzvKUzek
  7. public WordPairList(String[] words) {
  8. allPairs = new ArrayList<WordPair>();
  9. for (int i=0; i<words.length-1; i++) {
  10. for (int j=i+1; j<words.length; j++) {
  11. allPairs.add(new WordPair(words[i],words[j]));
  12. }
  13. }
  14. }
  15. public int numMatches() {
  16. int count = 0;
  17. for (int i=0; i<allPairs.size(); i++) {
  18. if (allPairs.get(i).first.contentEquals(allPairs.get(i).second)) {
  19. count++;
  20. }
  21. }
  22. return count;
  23. }
  24. public static void main(String[] args) {
  25. // TODO Auto-generated method stub
  26.  
  27. }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement