This question already has an answer here:
- Java Scanner why is nextLine() in my code being skipped? 2 answers
- Skipping nextLine() after use nextInt() 7 answers
String nameOfMovie;
int yearofMovie;
String GenreOfMovie;
String nameOfDirector;
ArrayList<String> actors = new ArrayList<String>();
System.out.println("Enter the year of movie");
yearofMovie = input.nextInt();
System.out.println("Enter the name of movie");
nameOfMovie = input.nextLine();
System.out.println("Enter the genre of movie(WARNING!If it has 2 or more genres,type them by typing dash between each genre.For example,war-drama)");
GenreOfMovie = input.nextLine();
System.out.println("Enter the name of director");
nameOfDirector = input.nextLine();
Firstly,ı type year then ı type name of movie.But it assigns the name to genre of movie instead name of movie.What is the problem on it?
Output:
Enter the year of movie
2014
Enter the name of movie
Enter the genre of movie(WARNING!If it has 2 or more genres,type them by typing dash between each genre.For example,war-drama)
Aucun commentaire:
Enregistrer un commentaire