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 fruit";
    String st = "";
      Map<String,Integer> hashmap = new HashMap<>();
      ArrayList<String> majority = new ArrayList<>();
      String[] words = str.split(" ");
      for(String word:words){
          if(!hashmap.containsKey(word)){
              st=st+word+ " ";
             hashmap.put(word,1);
          }
      }
       for(Map.Entry<String, Integer> entry : hashmap.entrySet()){
           System.out.println(entry.getKey());
       }
       System.out.println(st);
    }
}

Embed on website

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