나는 클래스를위한 작은 프로젝트를 해왔다. 문제없이 완벽하게 실행되지만, 클래스의 자동 테스터들과 비교해 보면, 2 라인은 오류를 찾을 수 없다. 과정의 직원에게 질문하는 것은 아무도 없을 때 선을 검사하려고하기 때문일 수 있다고 말하지만 모든 스캔을 인쇄하려고 시도했지만 그와 같은 것을 발견하지는 못했습니다. 그건 내 코드에서 내가 가진 모든 검사의 :스캔 라인이 이탈하고 있습니까?
Scanner sc = new Scanner(System.in);
String sentence;
int choice;
System.out.println("Please enter a sentence:");
sentence = sc.nextLine();
printMenu(); // calls a function to print the menu.
// gets the require action
System.out.println("Choose option to execute:");
choice = sc.nextInt();
sc.nextLine();
(나는 마지막 sc.nextLine로 및없이 시도)
static void replaceStr(String str)
{
String oldWord, newWord;
Scanner in = new Scanner(System.in);
// get the strings
System.out.println("String to replace: ");
oldWord = in.nextLine();
System.out.println("New String: ");
newWord = in.nextLine();
// replace
str = str.replace(oldWord, newWord);
System.out.println("The result is: " + str);
in.close();
}
static void removeNextChars(String str)
{
Scanner in = new Scanner(System.in);
String remStr; // to store the string to replace
String tmpStr = ""; //the string we are going to change.
int i; // to store the location of indexStr
// gets the index
System.out.println("Enter a string: ");
remStr = in.nextLine();
i=str.indexOf(remStr);
in.close(); // bye bye
if (i < 0)
{
System.out.println("The result is: "+str);
return;
}
// Build the new string without the unwanted chars.
/* code that builds new string */
str = tmpStr;
System.out.println("The result is: "+str);
}
라인이 여기에 누설 할 수있는 방법 어떤 생각?
정확한 오류 란 무엇인가요? –
[스캐너 No 라인 발견 예외] (http://stackoverflow.com/questions/7688710/scanner-no-line-found-exception) –
Richard - 코드가 오류를 제공하지 않으며, 예상대로 작동하지 않습니다. . 이 클래스의 자동 테스터는 "No line found"라고 말하면서 더 이상의 세부 사항을 언급하지 않습니다. 그리고 그래, 나는 이미 그것을 보았다. 하지만 도와 줘서 고마워. – Nescio