실험실 작업을위한 프로그램을 유니에서 쓰고 있는데, 코드가 무엇을하는지 분명하게 알 수 있지만, 첫 번째 줄, 즉 루프의 1 번을 요구할 때 , 당신은 문자열을 삽입하고 입력 히트, 그것은 자동으로 루프의 마지막 증분 (5) 어떤 아이디어로 바로 점프?for 루프가 모든 증분을 반복하지 않음
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.Scanner;
public class limmerickWriter {
public static void main(String[] args)throws Exception {
Scanner limScan = new Scanner(System.in); //scanner to read user input
System.out.println("please enter the name of the file");
String fileName;
fileName = limScan.next(); //filename for the text file
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(fileName))); //declaring a new file writer
for (int i = 1; i <= 5; i++) //loop to get 5 seperate lines from the user
{
System.out.println("please enter line " + i);
out.println(limScan.next()); //writes the contents of the scanner to the file
}
out.flush();
out.close();
}
}
디버깅을 시도 했습니까? 코드는 나에게 잘 보입니다. – Paranaix
Eclipse IDE를 사용하고 있으므로 컴파일하기 전에 자동으로 디버그됩니다. – srheayns
아니요. "디버깅"은 디버거에서 코드를 실행하거나 응용 프로그램에 디버거를 연결하는 것을 의미합니다. –