[JAVA] Loop double printing, can’t find the problem - HELP PLS
Long story short, I have made an application to order movie tickets. In some places the console is double printing things, and I cannot find the error. There’s two problems but to make this less cluttered I’ll focus on the first. ‘films’ refers to an array containing different movie titles. ‘numberSelection’ is for the user to input which movie they’d like to select based on the array. /////////////////////////////////////////////////////////// private static Film filmSelection() { int numberSelection: System.out.println(“Which film would you like to watch:”); for(int i=1;i<films.length;i++) { System.out.println(i + “ “ + films[i]); } numberSelection = scan.nextInt(); if(numberSelection >= 1 && numberSelection <= 4){ return films[numberSelection]; } else { return null } } /////////////////////////////////////////////////////////// The current console output is the print statement is: 1 MovieTitleHere 2 MovieTitleHere 3 MovieTitleHere 4 MovieTitleHere (Scanner input here) 1 MovieTitleHere 2 MovieTitleHere 3 MovieTitleHere 4 MovieTitleHere (Scanner input here *notice how it duplicates *the duplication doesn’t show until the first scanner input has been entered.