0
public class SplitTest {
public static void main(String[] args) {
String string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
String[] strToSplit = new String[] { "GH", "MN" };
for (String de : strToSplit) {
if (string.contains(de)) {
String[]str = string.split(de);
for (int i = 0; i < str.length; i++) {
System.out.println(str[i]);
}
}
}
}
}
ABCDEF,IJKLMNOPQRSTUVWXYZ,ABCDEFGHIJKL,OPQRSTUVWXYZ
,但實際產量:
ABCDEF,IJKL,OPQRSTUVWXYZ
[運行你的程序產生你期望的輸出](http://ideone.com/bmMxVv)。投票結束,不可重複。 – dasblinkenlight