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. String text = "<%1$s> %2$s";
  13.  
  14. String otherText = "HELLO";
  15. String sp="<%1$s";
  16. int index=text.indexOf(sp);
  17. //System.out.println(index+" "+(index+sp.length()));
  18. String newText="";
  19. for(int i=0;i<text.length();i++){
  20.  
  21. if(i==(index+sp.length()))
  22. newText +=otherText;
  23. newText +=text.charAt(i)+"";
  24.  
  25. }
  26. System.out.println(newText);
  27.  
  28. }
  29. }
Success #stdin #stdout 0.09s 320576KB
stdin
Standard input is empty
stdout
<%1$sHELLO> %2$s