Write code to walk backward to find if a char within srcString is in validString
//package com.book2s; public class Main { public static void main(String[] argv) { String srcString = "book2s.com"; String validString = "com"; System.out.println(lastIndexOfAnyBut(srcString, validString)); }// w ww . j a v a2 s . c om public static int lastIndexOfAnyBut(String srcString, String validString) { int result = -1; int srcLen = srcString.length(); // walk backward to find if a char within srcString is in validString for (int i = srcLen - 1; i >= 0; i--) { // not found, stop it if (validString.indexOf(srcString.charAt(i)) == -1) { result = i; break; } } return result; } }