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. reverseStringAfterAComma rsac = new reverseStringAfterAComma();
  13. String str = "grdwe,erwd";
  14. rsac.reverseMethod(str);
  15. }
  16. public static class reverseStringAfterAComma {
  17.  
  18. public void reverseMethod(String word) {
  19. char ch1 = ' ';
  20. char ch2 = ' ';
  21. String result = "";
  22. for (int a = 0; a < word.length(); a++) {
  23. if (word.charAt(a) == ',') {
  24. for (int i = word.length() - 1; i > a; i--) {
  25. ch1 = word.charAt(i);
  26. result += ch1;
  27. }
  28. for (int j = 0; j < a; j++) {
  29. ch2 = word.charAt(j);
  30. result += ch2;
  31. }
  32. }
  33. }
  34.  
  35. System.out.println(result);
  36. }
  37. }
  38. }
Success #stdin #stdout 0.09s 27656KB
stdin
Standard input is empty
stdout
dwregrdwe