Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int index = 0;
- String rev = "";
- for(int i = s.length()-1;i>=0;i--){
- rev+=s.charAt(i);
- }
- String x = rev;
- for(int i = 0;i<x.length();i++){
- for(int j = 0; j<chars.length();j++){
- if(x.charAt(i)==chars.charAt(j)){
- index = i;
- }else {
- index = -1;
- }
- }
- }
- System.out.println(index);
- return index;
- }
- /*I KNOW WHY THIS CODE doesn't work, just tell me how I can get a code for what I asked in the question. PLease try to keep it simple with no arrays because I am in a introductory java college course.*/
Add Comment
Please, Sign In to add comment