im having great trouble with my program. It's very simple, and i've completed it to the last step. Now though, I cant get the forloop to work and print out the name of movies.
insertMov creates three movie objects. The objects contain name, language and rating. I think it could be a problem with my scanner but im not sure. Thanks!
`import java.util.Scanner;
public class MovieRecommendation{
Movie [] movarr = new Movie[3];
Scanner scanner = new Scanner(System.in);
public void insertMov() {
movarr[0] = new Movie ("Avengers", "english", 2013, "pg" );
movarr[1] = new Movie ("Ironman", "english", 2008, "pg" );
movarr[2] = new Movie ("fantastic 4", "english", 2005, "pg" );
}
public String main() {
insertMov();
System.out.println("Hey, I hear you want to watch a movie.");
System.out.println("what language do you want the movie to be in?");
String langInp = scanner.nextLine();
System.out.println("Thanks! Now, what rating would you like your movie to be?");
String ratInp = scanner.nextLine();
System.out.println("Awesome :D Here are the movies Chosen for you");
for (int i = 0; i < movarr.length; i++ ){
if ( langInp == movarr[i].getLanguage() && ratInp == movarr[i].getRating()) {
System.out.println(movarr[i].getName());
}
}
return ("Feel free to use again");
}
}`