필자는 내 자신의 단어 사전을 만들었고 배열로 만들고 내 사전 배열과 비교하여 사용자 입력의 철자가 올바른지 확인하려고합니다. 문제는 내 결과에 입력 한 단어의 철자가 잘못되었다는 것입니다.자바의 맞춤법 검사기
import java.util.*;
public class SpellCheck {
public static void main(String args[]){
String array[] = {"This", "is", "a", "string"}; // Dictionary
System.out.println("Please enter a sentence");
Scanner a = new Scanner(System.in);
String line = a.nextLine();
System.out.println(line);
String arr[] = line.split(" "); // Turning into an array
for(int i = 0; i<array.length; i++){ // Loop that checks words
for(int j=0; j<arr.length; j++){
if(array[i].equals(arr[j])){
System.out.println(arr[j] + " is spelled correctly");
}
else{
System.out.println(arr[j] + " is not spelled correctly");
}
}
}
}
}
첫 번째 질문을 수정해야합니다. 주변에 나쁜 질문과 사본이있는 것은 좋지 않습니다. – djechlin
조언 : 첫 번째 질문을 편집하여 newone을 작성하십시오. –
어떤 입력을 사용하고 있습니까? – Christian