Write the java Program to reverse the letters present in the given string.
public class Main {
public static void main(String[] args) {
String data = "Test string";
char[] tmp = new char[data.length()];
for (int i = data.length() - 1, j = 0; i >= 0; i--, j++) {
tmp[j] = data.charAt(i);
}
System.out.println(new String(tmp));
}
}
Comments
Leave a comment