0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

JavaのStringクラスのメソッドいろいろ

Last updated at Posted at 2020-05-31

文字列調査に関するメソッド

メソッド 操作 引数型 戻り値型
equals 内容が等しいかどうか調べる String boolean
equalsIgnoreCase 大文字、小文字の区別を無視して内容が等しいかどうか調べる String boolean
length 文字列の長さを調べる String int
isEmpty 空文字かどうか調べる String int

文字列検索に関するメソッド

メソッド 操作 引数型 戻り値型
contains 文字列が含まれるかどうか調べる String boolean
startsWith 指定された文字列で始まるかどうか調べる String boolean
endsWith 指定された文字列で終わるかどうか調べる String boolean
indexOf 指定された文字または文字列が最初に登場する位置を調べる String int
lastIndexOf 指定された文字または文字列が後ろから検索して最初に登場する位置を調べる String int

文字列切り出しに関するメソッド

メソッド 操作 引数型 戻り値型
charAt 指定位置の1文字を切り出す int String
startsWith 指定された文字列で始まるかどうか調べる String boolean
endsWith 指定された文字列で終わるかどうか調べる String boolean
indexOf 指定された文字または文字列が最初に登場する位置を調べる String int
lastIndexOf 指定された文字または文字列が後ろから検索して最初に登場する位置を調べる String int

文字列変換に関するメソッド

メソッド 操作 引数型 戻り値型
toLowerCase 大文字を小文字に変換 String String
toUpperCase 大文字を小文字に変換 String
trim 前後の空白を除去 String
replace 指定された文字列に置き換える String,String String
reverse 指定された文字列を反転 String

参考文献

スッキリわかるJava入門実践編

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?