0

Строка наоборот

У меня получается строка наоборот, не могу понять в чем моя ошибка, помогите пожалуйста https://code.sololearn.com/cBDxFZ2RMO84/?ref=app

27th Aug 2022, 4:02 PM
Akridem
Akridem - avatar
2 Answers
0
// read the comments for corrections need 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 = str.toCharArray(); // str is undefined, must be text.toCharArray() String result = "hello there"; for (int i = array.lenght - 1; i>= 0; i--) { // spelling mistake in lenght (=> length) and array is undefined, may ypu mean arr.length result = result + array[i]; // arr[i] } return result; // this is not needed, main is void. // Are you trying to print then use System.out.print(result); } }
29th Aug 2022, 8:48 AM
Jayakrishna 🇮🇳
0
Thanks you wery mach!!!!!!!!!!!!!!!!!!
9th Sep 2022, 4:04 PM
Akridem
Akridem - avatar