// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.util.ArrayList;
import java.util.List;

public class Bad {
    private static List<String> wordlist = new ArrayList<String>();
    static {
        wordlist.add("Moscow");
        wordlist.add("Leningrad");
        wordlist.add("is");
        wordlist.add("was");
        wordlist.add("the");
        wordlist.add("a");
        wordlist.add("capital");
        wordlist.add("state");
        wordlist.add("of");
        wordlist.add("by");
        wordlist.add("Russia");
        wordlist.add("Romania");
    }
    public static void test(String s) {
        for(String w : s.split("\\W")) {
            int ix = wordlist.indexOf(w);
            if(ix >= 0) {
                System.out.println(w + " -> " + wordlist.get(ix + 1));
            } else {
                System.out.println(w);
            }
        }
    }
    public static void main(String[] args) {
        test("Moscow is the capital of Russia X");
    }
}
