강의

멘토링

로드맵

Inflearn Community Q&A

ikkw20404308's profile image
ikkw20404308

asked

Introduction to Java Algorithm Problem Solving: Coding Test Preparation

7. Palindrome String

왜 오류가 생길까요?

Written on

·

274

0

import java.util.*;

class Main {

    public String solution(String str) {
        String answer = "YES";
        str.toLowerCase();
        for (int i = 0; i < str.length() / 2; i++) {

            if (str.charAt(i) == str.charAt(str.length() - i - 1)) {
                answer = "YES";
            } else {
                answer = "NO";
            }

        }

        return answer;

    }

    public static void main(String[] args) {
        Main T = new Main();
        Scanner sc = new Scanner(System.in);

        String str = sc.next();

        System.out.println(T.solution(str));

    }
}
 
 
이게 왜 오류나는지 궁금합니다...
코테 준비 같이 해요! java

Answer

This question is waiting for answers
Be the first to answer!
ikkw20404308's profile image
ikkw20404308

asked

Ask a question