import java.util.*;
import java.lang.*;
import java.io.*;

// The main method must be in a class named "Main".
class Main {
    public static void main(String[] args) {
       String str = "this is manasa the manasa the the manasa the manasa is is the";
      Map<String,Integer> hashmap = new HashMap<>();
      ArrayList<String> majority = new ArrayList<>();
      String[] words = str.split(" ");
      for(String word:words){
          if(hashmap.containsKey(word)){
              hashmap.put(word, hashmap.get(word)+1);
          }
          else
          hashmap.put(word,1);
      }
      for(Map.Entry<String, Integer> entry : hashmap.entrySet()){
          if(entry.getValue()>words.length/3){
              majority.add(entry.getKey());
          }
      }
      System.out.println(words.length/3);
       System.out.println(majority);
       System.out.println(hashmap);
    }
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: