https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html#substring(int)
String (Java SE 11 & JDK 11 )
Compares two strings lexicographically. The comparison is based on the Unicode value of each character in the strings. The character sequence represented by this String object is compared lexicographically to the character sequence represented by the argum
docs.oracle.com
substring
부분 문자열을 구해보자.
public String substring(int beginIndex)
beginIndex 위치부터 문자열 끝까지의 부분 문자열 반환
beginIndex가 음수거나 문자열의 길이보다 크면 IndexOutOfBoundException 발생
public String substring(int beginIndex, int endIndex)
beginIndex부터 endIndex - 1 위치까지의 부분 문자열 반환
부분 문자열의 길이는 endIndex - beginIndex이다.
beginIndex가 음수거나, endIndex가 문자열의 길이보다 크거나, beginIndex > endIndex인 경우 IndexOutOfBoundException 발생
'공부한 거 > Java' 카테고리의 다른 글
| [Java] 향상된 for문 (0) | 2024.02.05 |
|---|---|
| [Java] BufferedReader,StringBuilder (0) | 2023.09.22 |