Please try to solve it by yourself first and if possible post your errors/exception rather than posting the question.
public class StringProblem {
private String stringInstance;
private char[] splittedString;
public StringProblem(String initString) {
stringInstance = new String(initString);
splittedString = stringInstance.toCharArray();
}
public int length() {
return splittedString.length;
}
public char charAt(int index) {
return splittedString[index];
}
public static void main(String[] args) {
StringProblem strProb = new StringProblem("NEPAL");
for (int i = strProb.length() - 1; i >= 0; i--) {
System.out.print(strProb.charAt(i) + " ");
}
}
}