코딩테스트

Java String 코테 준비용

yolang 2025. 1. 31. 21:56
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