*/
package com.org.improve.contact.indexof;public class BoradMatch { public static boolean isBoradMatch(String parent, String children){ String[] childrenItems=children.split(" ");//以空格为分隔符 for (String childrenItem:childrenItems) { if (parent.indexOf(childrenItem)==1) { return false; } } return true; } public static void main(String[] args) { StringBuffer result=new StringBuffer(); String parent="cheap iphone in china"; String [] dicts={"cheap iphone","cheap mobile","in china"}; for (int i = 0; i < dicts.length; i++) { if (isBoradMatch(parent,dicts[i])) { result.append(",").append(i+1); } } if (result.length()>0) { System.out.println("匹配的结果为:"+result.substring(1)); } else{ System.out.println("无任何匹配结果!"); }}}