fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12.  
  13. Map<String, String> abbrev = new HashMap<String, String>();
  14. abbrev.put("tran.", "translae");
  15. abbrev.put("wo.", "words");
  16. abbrev.put("f.", "for");
  17.  
  18. String str="tran. all of the wo. f. me";
  19. String[] words = str.split(" ");
  20. String result = "";
  21.  
  22. for (String word : words) {
  23. if(abbrev.get(word) != null){
  24. result= result+ abbrev.get(word);
  25. }else{
  26. result= result + word;
  27. }
  28. result = result + " ";
  29. }
  30. System.out.println(result);
  31. }
  32. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
translae all of the words for me