0

Can any one send , simple example of string reverse????

20th Nov 2016, 2:15 PM
ravi
5 Respuestas
+ 6
public static String reverse(String input) { char[] in = input.toCharArray(); int begin=0; int end=in.length-1; char temp; while(end>begin) { temp = in[begin]; in[begin]=in[end]; in[end] = temp; end--; begin++; } return new String(in); }
20th Nov 2016, 4:15 PM
Remmae
Remmae - avatar
+ 1
basicly the same, but without the need of two variables for counting and no placeholder variable. public static String reverse(String input) { char[] in = input.toCharArray(); char[] out = new char[in.length]; for(int i = 0; i < in.length; i++) { out[i] = in[in.length - i -1]; } return new String(out); }
20th Nov 2016, 7:01 PM
Roland
+ 1
Easiest method is to create a string buffer from the string and call the reverse method.
27th Nov 2016, 7:33 PM
Sourav Kumar Ghosh
Sourav Kumar Ghosh - avatar
0
instead of doing all these.....you can directly use reverse method
21st Nov 2016, 6:47 AM
kamal singh bankoti
kamal singh bankoti - avatar
0
yes you can see some examples in my code blog. their is String some examples you can understand easy.
23rd Dec 2016, 5:00 AM
Alok Kumar
Alok Kumar - avatar