25th Feb 2020, 1:03 PM
Piyush Srivastava
Piyush Srivastava - avatar
5 Antworten
+ 4
Swap function does not effect on original values, Since you are doing it by call by value, not by reference. Swap values in loop itself... Edit: alternatively use @zemiak suggestion.
25th Feb 2020, 1:12 PM
Jayakrishna 🇮🇳
+ 3
You can do directly by print string backwards. ----------------------------------------------------- ----------------------------------------------------- for(int i = s.length()-1; i>=0; i--){ System.out.print(s.charAt(i)); } ----------------------------------------------------- -----------------------------------------------------
25th Feb 2020, 5:33 PM
Vishal
+ 2
use swap(c, i, j); ... public static void swap(char[] arr, int a, int b){
25th Feb 2020, 2:49 PM
zemiak
+ 2
Thank guys
27th Feb 2020, 5:26 AM
Piyush Srivastava
Piyush Srivastava - avatar