What is the end of the text to reverse It to print the input text reversed??! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the end of the text to reverse It to print the input text reversed??!

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(); for (string i=text;i<arr.length;i--){ arr[i]=i; } System.out.println(arr[i]); //your code goes here } }

24th Mar 2022, 11:10 PM
Ebrahim Lotfy
Ebrahim Lotfy - avatar
2 Answers
+ 5
You need to review or research and try to code the part where it says. If it doesn't work, share your attempt by using the code playground and someone can help.
24th Mar 2022, 11:38 PM
Ausgrindtube
Ausgrindtube - avatar
+ 1
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(); //convert into character array for(int i=arr.length-1; i>=0; i--){ //print from last index to first by System.out.print(arr[i]); } } } // String i=text; valid but i--, i<arra.length are invalid. //hope it helps..
25th Mar 2022, 9:37 AM
Jayakrishna 🇮🇳