LoginSignup
0

More than 1 year has passed since last update.

文字列を桁数で区切る

Last updated at Posted at 2022-09-08

PG

public static final int array[][] =
    {
        {0,4},
        {4,9},
        {9,12},
        {12,15}
    };
public void test3() {


    	String mojiretsu = "12あ41 345 23111";
    	String conv = "";
        for(int i = 0; i<array.length; i++){
        	int mae = 0;
        	int ushiro = 0;
            for(int j = 0; j<array[i].length; j++){
            	if(j == 0) {
            		mae = array[i][j];
            	}else {
            		ushiro = array[i][j];
            	}
            }
            System.out.println(mojiretsu.substring(mae, ushiro));
        }
}

結果

12あ4
1 345
 23
111

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0