2
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?

問題

「Dランク:文字列の一致」

コード

Javaで解いてみました。

import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String sA = sc.next();
        String sB = sc.next();
        
        if (sA.equals(sB)) {
            System.out.println("OK");
        } else {
            System.out.println("NG");
        }
    }
}

解説

標準入力からの文字列の読み取り

Scanner インスタンスを作り、next()メソッドで文字列を取得しています。

文字列の比較

String クラスの equals() メソッドで、文字列が一致するか調べています。

2
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
2
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?