å¤æä¸ä¸ªå符串ä¸æ¯å¦å
å«æ个å符串æ¹æ³å¦ä¸ï¼
public class Test {
// åæ°æ¯éè¦å¤æçåå符串
public void judge(String subString) {
String string = "judge is subString";
// è¿åæå®åå符串å¨æ¤å符串ä¸ç¬¬ä¸æ¬¡åºç°å¤çç´¢å¼ãå¦æå®ä¸ä½ä¸ºä¸ä¸ªåå符串åºç°ï¼åè¿å -1ã
if (string.indexOf(subString) == -1) {
System.out.println("æ¤å符串ä¸ä¸å«" + subString + "è¿ä¸ªåå符串");
} else {
System.out.println("æ¤å符串ä¸å«æ" + subString + "è¿ä¸ªåå符串");
}
}
// 主æ¹æ³
public static void main(String[] args) {
Test test = new Test();
test.judge("sub");
}
}
è¿è¡ææï¼