+ 1
Write a javaprogram to take input as string and result reverse of it
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String text = scanner.nextLine(); char[] arr = text.toCharArray(); String s=""; for(int i=arr.length-1;i<arr.length ;i--){ s=arr[i] + s; } //your code goes here System.out.println(s); } } Can anyone help me to correct my code!!!
2 Answers
+ 3
for(int i=arr.length-1;i>=0;i--){
s=s+arr[i];
}
+ 2
Thank you