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?

Javaにおける回分判定について

Posted at

Javaで回分判定を書いてみる。

初心者ながら回文判定を書いてみた。

import java.util.*;

public class Main {
    	public static void main(String... args) {
    	Scanner sc = new Scanner(System.in);
    	String input= sc.next();
 	StringBuilder reversedInput = new StringBuilder(input).reverse();
sc.close();
 	
if (input.equals(reversedInput.toString())) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
     }
  }
}

自分がつまったのは、StringBuilderを使うところで、どうやってやればええねんとなりました。

reverse();

をつけるのを忘れずに。

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?