Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7850297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:48:14+00:00 2026-06-02T18:48:14+00:00

Hey I’m trying to take a String input from the user (in this case

  • 0

Hey I’m trying to take a String input from the user (in this case a name of a film e.g. Good Burger). I have an arraylist of class Film from which I’m iterating through. On each iteration a method in the instance of class Film is called which returns a String of the film name. When I’m comparing these two, it doesn’t seem to recognise that they are equal and I can’t figure out why.

Heres the code that’s taking the input and comparing the two:

//Get the films input by the user.

    int numberOfFilmsCheck;
    numberOfFilmsCheck = 0;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    Film tempFilm;
    System.out.println("Please enter the names of the films you wish to be in the new schedule");
    System.out.println("Press enter after each one.");

    while(numberOfFilmsCheck < numberOfFilms){
        boolean foundFilm;
        foundFilm = false;
        String inputFilmName = null;
        tempFilm = null;
        String filmName;
        filmName = null;
        try{
            inputFilmName = reader.readLine();
            System.out.println(inputFilmName);
        }
        catch (IOException e){
            System.out.println("Error");
        }

        for(Film film : films){
            film.printFilmName();
            if(inputFilmName.equals(filmName)){
                foundFilm = true;
                tempFilm = film;
                System.out.println("Found film name");
                break;
            }
        }

        if(foundFilm == true){
            newFilmsForSchedule.add(tempFilm);
            numberOfFilmsCheck++;
        }
        else{
            System.out.println("The film you entered has not been recognised.");
            System.out.println("Please enter the film name as shown above.");
        }

and here is the code in class Film that returns the film name:

public String getFilmName()
{
    return filmName;
}

If you notice any rogue print statements in there that’s just me checking the code is working correctly.

Any help is much appreciated! Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:48:15+00:00Added an answer on June 2, 2026 at 6:48 pm

    The getFilmName() function looks like quite a useful one, but only if you end up calling it 🙂

    You appear to set filmName to null at the start, then you never actually change it (by calling getFilmName(), for example). Hence, it will be null for the purposes of comparison.

    I suspect you may need something like:

    for(Film film : films){
        film.printFilmName();
        filmName = film.getFilmName();               // <-- Added this.
        if(inputFilmName.equals(filmName)){          // <-- So that this works.
            foundFilm = true;
            tempFilm = film;
            System.out.println("Found film name");
            break;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hey guys I have the follow code in js: $(document).ready(function(){ $(.replyLink).click(function(){ $(#form-to-+this.id).html(htmlForm()).toggle(500); return false;
Hey all i have two JFrames one is my main login frame, user enters
Hey all i have an XML file that i am trying to loop though.
Hey guys I'm running this code in Android: public ServiceServer(String serverName) { this.serverName =
hey guys, I have mypage.com/user-login.php?action=register and I want to be able to call mypage.com/register
Hey guys I have a weird problem trying to use a global array in
Hey, I have a problem in Multithreading. To describe this, I have two threads.
Hey I am getting this error: error: conversion to non-scalar type requested Here are
hey guys how to make these php html links codes possible. i have tried
Hey I'm building an app that will allow a user to log into a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.