java.lang.String.split()で文字列を分割するサンプルコード

javaコード
import java.util.Arrays;
public class SplitTest {

public static void main(String[] args) {
String strText = “Oosaki123Station456";

for (int i = 0; i < 4; i++) {
String[] kk = strText.split(“[0-9]", i);
System.out.println(“count=" + i + “\r" + “kk=" + Arrays.toString(kk));
}

}

}
結果
count=0
kk=[Oosaki, , , Station]
count=1
kk=[Oosaki123Station456]
count=2
kk=[Oosaki, 23Station456]
count=3
kk=[Oosaki, , 3Station456]

Java

Posted by arkgame