3
0

問題文

解答例

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			String a = scanner.next();
			String b = scanner.next();

			if (a.equals(b)) {
				System.out.println("OK");
			} else {
				System.out.println("NG");
			}
		}
	}
}

補足

ポイントはJavaで文字列を比較する際==を使わないこと。
説明は(ちょっと難しめだが)以下が詳しい。
https://developer.mamezou-tech.com/blogs/2022/11/06/java-string-equals/

3
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
3
0