Java standard class simple memo A method that partially counts the number of characters
【substring】 ・ Select characters after the specified position How to use: Variable = String Variable.substring (start position number);
-Select characters from the specified position to the specified position (partial selection) How to use: Variable = string Variable.substring (start position number, end position number)
ex) String word = "ABCDEFGHI"; Image like 0 = A, 1 = B, 2 = C ... //ex) public static void main(String[] args){ //String変数wordにABCDEFGHIを格納 String word = "ABCDEFGHI"; //String変数selectWordに"E"以降の文字を格納 String selectWord = word.substring(4); //String変数を表示 System.out.println(selectWord); //"F"以降を直接表示 System.out.println(word.substring(5));
//"BからG"までの文字を直接表示 System.out.println(word.substring(1,7)); }
Recommended Posts