Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Comparator;
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author INT303
- */
- public class WordCounter {
- private String word;
- private int count;
- public WordCounter(String word) {
- this.word = word;
- this.count = 1;
- }
- public String getWord() {
- return word;
- }
- public int getCount() {
- return count;
- }
- public void increment(){
- this.count++;
- }
- @Override
- public String toString() {
- return "WordCounter{" + "word=" + word + ", count=" + count + '}';
- }
- public static Comparator<WordCounter> getFreqDescComparator(){
- return new Comparator<WordCounter>(){
- @Override
- public int compare(WordCounter wc1, WordCounter wc2){
- return wc2.getCount() - wc1.getCount();
- }
- }
- return ; -----------------------------------------------------
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement