vendredi 13 mars 2015

Why isn't nextLine() statement working correctly in java? [duplicate]





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