1. toUpperCase()
public String toUpperCase()
- 문자열에 있는 모든 문자를 대문자로 치환한다.
ex)
String s = "abcdEfg";
System.out.println(s.toUpperCase());
실행 결과)
2. toLowerCase()
public String toLowerCase()
- 문자열에 있는 모든 문자를 소문자로 치환한다.
ex)
String s = "ABCdEFG";
System.out.println(s.toLowerCase());
실행 결과)
3. equalsIgnoreCase()
public boolean equalsIgnoreCase(String anotherString)
- 대소문자 조건을 무시하고 문자열을 비교한다.
매개변수
- anotherString : 비교 대상이 되는 string 문자
ex)
String s1 = "ABCdefG";
String s2 = "abcdefg";
System.out.println(s1.equals(s2));
System.out.println(s1.equalsIgnoreCase(s2));
실행 결과)
s1.equals(s2)의 실행결과는 대소문자까지 비교하므로 false가 출력된다.
s1.equalsIgnoreCase(s2)의 실행결과는 대소문자를 비교하지 않으므로 true가 출력된다.
'java' 카테고리의 다른 글
[210120] Java Optional (0) | 2021.01.20 |
---|---|
[210118] java Stream (1) - stream 정의와 관련 메소드 (0) | 2021.01.18 |
[210116] java comparable & comparator (0) | 2021.01.16 |
[210112] java collection (0) | 2021.01.12 |
[201216] lambda 및 함수적 인터페이스 (0) | 2020.12.16 |