์์ ์ธ๋ฑ์ค๋ง ์ง์
์์ ์ธ๋ฑ์ค n ~ ๋๊น์ง ์ถ๋ ฅ
public class Example {
public static void main(String[] args) {
String str = "Hello, World!";
String result = str.substring(7); // 7๋ฒ ์ธ๋ฑ์ค๋ถํฐ ๋๊น์ง
System.out.println(result); // ์ถ๋ ฅ: "World!"
}
}
์์๊ณผ ๋ ์ธ๋ฑ์ค ๋ชจ๋ ์ง์
์์ ์ธ๋ฑ์ค n ~ ๋ ์ธ๋ฑ์ค n2 ์ ๊น์ง ์ถ๋ ฅ
n2๋ ์ถ๋ ฅ์ ๋ฏธํฌํจ !!
public class Example {
public static void main(String[] args) {
String str = "Hello, World!";
String result = str.substring(0, 5); // 0๋ถํฐ 5๋ฒ ์ธ๋ฑ์ค๊น์ง (5๋ ๋ฏธํฌํจ)
System.out.println(result); // ์ถ๋ ฅ: "Hello"
}
}