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 1 year has passed since last update.

Java 文字列(String)同士の比較

Last updated at Posted at 2023-03-01
1 / 2

Javaでは、int型とString型では比較する際に違いがある。

・int型   「==」
・String型 「equals」

上記の二つで比較します。
実際に「equals」を使ってみます。

public static void main(String[] args){

    String name = "林";
    if(name.equals("林"){
        System.out.println(name);
    }
}

 [説明]
・1行目で変数nameに「林」を代入
・2,3行目は「もしname変数が「林」なら、変数name(林)を出力する

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?