+ 1

Am trying to get a char in string in java by using name.charAt(3);. The compiler keeps telling me variable charAt error

8th Jun 2020, 10:06 AM
Grandizer
Grandizer - avatar
4 ответов
+ 1
Ooh🤣
8th Jun 2020, 10:32 AM
Grandizer
Grandizer - avatar
0
public class Main { public static void main(String[] args) { String test = "hello!"; char[] letters = new char[test.length()]; int index = 0; for(int i =test.length()-1;i>=0;i--) { letters[index]=test.charAt[i]; index++; } String rev=""; for(int i=test.length()-1;i>=0;i++) { rev+=letters [i]; } System.out.println(rev); } }
8th Jun 2020, 10:30 AM
Grandizer
Grandizer - avatar