fork(1) download
  1.  
  2. import java.util.*;
  3. import java.lang.*;
  4. import java.io.*;
  5.  
  6. /* Name of the class has to be "Main" only if the class is public. */
  7. class StringReverseInPlace
  8. {
  9. static char[] reverse(char[] name, int len) {
  10. // int l = name.length();
  11. int j,i = 0;
  12. char temp;
  13. for(i = 0, j = len; i < j; i++,j--) {
  14. temp = name[i]; //swapping
  15. name[i] = name[j];
  16. name[j] = temp;
  17. }
  18. return name;
  19. }
  20.  
  21. public static void main (String[] args)
  22. {
  23. String name = "prakash";
  24. System.out.println(reverse(name.toCharArray(), name.length()-1));
  25. }
  26. }
  27.  
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
hsakarp