
/*
Online Java - IDE, Code Editor, Compiler

Online Java is a quick and easy tool that helps you to build, compile, test your programs online.
*/

import java.util.*;

public class Main
{
    public static void main(String[] args) {
        System.out.println("Welcome to Online IDE!! Happy Coding :)");
        String test="ssss ss";
        
        censor cs = new censor ();
        System.out.println("This is the string: " + cs.censor(test));
       
    }
}

class censor
{
    private String test;
    StringBuffer sb;
    int numberChars;
    StringJoiner sj = new StringJoiner(" ");
    
    public StringJoiner censor (String test)
    {
    
    this.test=test;
     StringTokenizer st = new StringTokenizer(test);
    int count=0;
    
        while (st.hasMoreTokens())   //looks for more words
        {
            
            if ((st.nextToken()).length()<=4)   //length is equal or less than 4
            {
                // count++;
                numberChars=st.nextToken().length();
                System.out.println(numberChars);
                
                sj.add(st.nextToken());
                
                //sb.append(" ");
                
               
                
            }
            else
            {
                 for (int j=0; j<numberChars; j++)
                 {
                    sb.append("*");
                }
                sj.add(sb);  //st.nextToken());
                
                sb.replace(0,sb.length()-1, "*");
                
            }
            
        }
        
        if (count==0)
        {
            sj.append(test);
            return sb;
        }
        return sb;
    
}
}
