강의

멘토링

커뮤니티

Inflearn Community Q&A

wellsbabo5259's profile image
wellsbabo5259

asked

Introduction to Java Algorithm Problem Solving: Coding Test Preparation

1. Find a Character

1-1 왜 런타임 에러가 나오는지 모르겠습니다

Written on

·

263

·

Edited

0

package org.example;
import java.util.Scanner;
import static java.lang.Character.*;


public class Main {
    public static int solution(String str, String ch){
        int result = 0;
        for(int i = 0; i < str.length(); i++){
            if(toLowerCase(str.charAt(i))  == toLowerCase(ch.charAt(0))){
                result++;
            }
        }
        return result;
    }



    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.next();
        String ch = scanner.next();
        System.out.println(solution(str, ch));
    }
}

IDE에서는 정상적으로 실행되는데

채점사이트에서는 런타임에러가 나네요 ㅠㅠ

이유를 모르겠습니다 

java코딩-테스트

Answer 1

0

wellsbabo님의 프로필 이미지
wellsbabo
Questioner

코드 맨 윗줄에 패키지 부분을 빼야하네요...

무지성 복붙했더니..

package org.example;
wellsbabo5259's profile image
wellsbabo5259

asked

Ask a question