開始位置を指定する場合
String.substring(int beginIndex)
public class Main {
public static void main(String[] args) {
String sports = "soccer,baseball,basketball";
System.out.println(sports.substring(7));
}
}
実行結果
baseball,basketball
開始、終了位置を指定する場合
String.substring(int beginIndex, int endIndex)
public class Main {
public static void main(String[] args) {
String sports = "soccer,baseball,basketball";
System.out.println(sports.substring(7, 15));
}
}
実行結果
baseball