728x90
String 은 "
Char은 '
String Methods
String hello = "hello world";
| Method | Description | Return | example |
| split() | 문자열 나누기 | String | hello.split(" "); |
| trim() | 양 끝의 whitespace 제거 | String | hello.trim(); |
| charAt() | 특정 index의 문자 가져오기 | char | hello.charAt(2); |
| equals() | 두 String이 같은 지 비교 | boolean | hello.equals("hello World"); // false |
| compareTo() | 두 String 비교해서 다른 문자 갯수 반환 | int | hello.compareTo("hello"); // 6 |
| length() | String의 길이 | int | hello.length(); |
| concat() | String 이어 붙이기 | String | hello.concat(" Good Morning"); |
| toCharArray() | character array로 바꾸기 | char[ ] | hello.toCharArray(); |
https://www.w3schools.com/java/java_ref_string.asp
728x90
'코딩테스트' 카테고리의 다른 글
| 삼성 SDS 2025년도 상반기 알고리즘 특강 기록 (0) | 2025.02.18 |
|---|---|
| 백준 9663 N-Queen (1) | 2025.02.03 |
| 백준 13317 한 번 남았다 (1) | 2025.01.25 |
| 백준 2179 비슷한 단어 (0) | 2025.01.23 |
| 프로그래머스 - 양과 늑대 (0) | 2025.01.23 |