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

  • Home
  • SEARCH
  • 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 6806643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:44:10+00:00 2026-05-26T19:44:10+00:00

So the problem I’m running into is I want to test each part of

  • 0

So the problem I’m running into is I want to test each part of an array against a condition, and if ALL the parts of the array return false I want to do something but if any of them return true I want to do something else. For example

  String[] arr = new String[8];
  for(String s : arr) {
    if(s.equalsIgnoreCase("example") {
      // Do this
    } else {
      // do that
    }
  }

The problem with the above is that is will do this or do that for all 8 pieces of the array. What I want is for it to test all of them, and if they’re all false do that but if any of them are true then do this.

  • 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-05-26T19:44:11+00:00Added an answer on May 26, 2026 at 7:44 pm

    The previous answer has the conditions backwards. It was testing if ANY is FALSE, “Do this” and if ALL are TRUE “Do that”. Try this code:

    String[] arr = new String[8];
    boolean found = false;
    for(String s : arr) {
        if(s.equalsIgnoreCase("example")) {
            found = true;
            break;
        }
    }
    if(found) {
        // Do this
    } else {
        // Do that
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
Problem: I have two spreadsheets that each serve different purposes but contain one particular
Problem solved: Thanks guys, see my answer below. I have a website running in
Problem: I need an array (datamember) in a parent class A. However, depending on
Problem statement: I want to upload a large binary (such as an audio clip)
Problem: Sometimes you will want to access a component from javascript with getElementById ,
Problem: I don't know why my script is not loading a value into the
Problem I need to replace all asterisk symbols('*') with percent symbol('%'). The asterisk symbols
Problem : The problem I’m having is when I zoom into my UIScrollView (with

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.