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 9000071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:15:51+00:00 2026-06-16T00:15:51+00:00

In the following code I check whether or not the given url ends with

  • 0

In the following code I check whether or not the given url ends with an allowed filetype (possible types: .jpg, .jpeg, .png & .gif). The list of types are saved in an arraylist which holds the textual description from the UI (e.g. “JPG Images”).

My intention is to make the function traverse trough the list with descriptions and check the url with their corresponding URL check methods.

I expected this code to work as I believe that every scenario has been accounted for: if it’s JPG, PNG or GIF it returns true, otherwise it returns false. It remains with an error though:

Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem: 
This method must return a result of type boolean

Which obviously means that the returns somewhere have gone wrong. What am I overlooking?

private boolean isImageURL(ImageURL url) {
    for (String type : fileTypes) {
        if (type.equalsIgnoreCase("JPG Images")) {
            if (url.isJPG() || url.isJPEG()) {
                return true;
            }
        } else if (type.equalsIgnoreCase("PNG Images")) {
            if (url.isPNG()) {
                return true;
            }
        } else if (type.equalsIgnoreCase("GIF Images")) {
            if (url.isGIF()) {
                return true;
            }
        } else {
            return false;
        }
    }
}
  • 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-16T00:15:51+00:00Added an answer on June 16, 2026 at 12:15 am

    All the possible execution paths are not covered. For example, if the type is “JPG Images”, but the url is neither JPG nor JPEG, the method doesn’t return anything.

    Remove the last else clause, and simply return false at the end of the method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the following code to check whether or not a certain div exists.
I am using the following code to check whether an object exists or not
I am using following code to check whether a check box on my website
Given the following code: $(.force-selection).blur(function() { var value = $('matched-item').val(); //check if the input's
I have been using the following code to check whether a dialog is already
I am using following code to check whether the Sd Card is present and
To check whether value is numeric in LS, I would write the following code:
I am using the following code to check whether the textbox value is changed.
I am adding the following code to check whether a checkbox should be checked
I wrote the following code In c just to check whether the code would

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.