Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- public class WordPairList {
- private ArrayList<WordPair> allPairs;
- //https://pastebin.com/KzvKUzek
- public WordPairList(String[] words) {
- allPairs = new ArrayList<WordPair>();
- for (int i=0; i<words.length-1; i++) {
- for (int j=i+1; j<words.length; j++) {
- allPairs.add(new WordPair(words[i],words[j]));
- }
- }
- }
- public int numMatches() {
- int count = 0;
- for (int i=0; i<allPairs.size(); i++) {
- if (allPairs.get(i).first.contentEquals(allPairs.get(i).second)) {
- count++;
- }
- }
- return count;
- }
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement