자바 문자입력시 미출력 구문

조회수 427회
import java.util.Scanner;

public class Song {
    private String title;
    private String artist;
    private int year;
    private String country;

    public void Song(){}

    public void Song(int year, String country, String artist, String title) {
        this.year = year;
        this.country = country;
        this.artist = artist;
        this.title = title;
    }


    void show() {
        System.out.println(year + "년 " + country + "국적의 " + artist +"가 부른 " + title);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            System.out.println("시작을 원하면 1 끝은 0 입력");
            int start = sc.nextInt();
            if(start == 0)
                break;
            else {
                System.out.println("년도, 국적, 가수, 제목 순으로 입력");
                int year = sc.nextInt();
                String country = sc.nextLine();
                String artist = sc.nextLine();
                String blank = sc.nextLine(); //이부분이 빠져있다면 title이 출력이 안되는데 이유가뭘까요?
                String title = sc.nextLine();
                Song song = new Song();
                song.Song(year, country,artist,title);
                song.show();
            }
        }

    }

}

만약 String blank = sc.nextLine(); 구문이 빠져있다면 2021 대한민국 아이유 라일락

이순서로 입력시에 라일락은 출력되자 않고, 2021년 대한민국 국적의 아이유가 부른 // 까지만 출력이 됩니다. 이유가 뭔가요?

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)