문자열 : 포함여부

misonaru·2022년 9월 21일

자바 공부

목록 보기
3/13

String str = "I LOVE MYSELF"

  • charAt(int)
str.charAt(5) = 'E'

 

  • indexOf('str')
str.indexOf("E") = 5

 

  • lastIndexOf('str')
str.lastIndexOf("E") = 10

 

  • contains('str')
 
str.contains("SELF") = true

 

  • startsWith('str')
str.startsWith("LOVE") = false

 

  • endsWith('str')
str.endsWith("SELF") = true

 

  • isEmpty()
str.isEmpty() = false

 

  • equals('str')
str = "KOREA";

str.equals("KOREA") = true

str.equals("korea") = false
=> str.equalsIgnoreCase("korea") = true

 

profile
미소와 나루 집사

0개의 댓글