+ 1
Am trying to get a char in string in java by using name.charAt(3);. The compiler keeps telling me variable charAt error
4 Respostas
+ 1
Ooh🤣
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);
}
}