Guest User

Untitled

a guest
Oct 22nd, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. int index = 0;
  2. String rev = "";
  3.  
  4. for(int i = s.length()-1;i>=0;i--){
  5. rev+=s.charAt(i);
  6. }
  7.  
  8. String x = rev;
  9.  
  10. for(int i = 0;i<x.length();i++){
  11.  
  12. for(int j = 0; j<chars.length();j++){
  13. if(x.charAt(i)==chars.charAt(j)){
  14. index = i;
  15. }else {
  16. index = -1;
  17. }
  18. }
  19. }
  20. System.out.println(index);
  21. return index;
  22. }
  23. /*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