/*
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 :)");
        StringBuilder sb = new StringBuilder();
        int k=0;
        int numberWords=0;
        
        String testSample = "My name is Amit Amlani";
        System.out.println("This is initial string: " + testSample + "\n");
        
        for (int i=0; i<testSample.length();i++)
        {
            if (testSample.charAt(i)==' ')
            {
                numberWords++;
            }
        }
        String [] words = new String[numberWords+1];
        StringJoiner sj = new StringJoiner(" ");
        StringTokenizer st = new StringTokenizer(testSample);
        String temp="";
        
        while (st.hasMoreTokens())
        {
            temp = st.nextToken();
            words[k]=temp;
            k++;
            
            System.out.println("here: " + temp);
            
            for (int q=0; q<temp.length(); q=q+2)
            {
                sb.append(temp.charAt(q+1));
                sb.append(temp.charAt(q));
            }
            
            sj.add(sb);
            sb.delete(0,sb.length());
        }
System.out.println("\n" + "Test string restored: => " + sj);
    }
}