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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:07:25+00:00 2026-05-22T17:07:25+00:00

This is a Java/Groovy question, im doing this function to implement in a search

  • 0

This is a Java/Groovy question, im doing this function to implement in a search mechanism in my website. I have two lists:

String [] lista = temp.split() // ignore the temp part
String [] searchLista = search.split() // ignore the search part

Basically, the lists are something like this:

    lista = {a, b, c, d}
    searchLista= {a, b, a, d}
    boolean test

I want to verify if, any element on list ‘lista’ is the same on ‘searchLista’. For that i did the following function:

for(int i = 0; i< lista.length-1; i++){

                for(int j = 0; j< searchLista.length-1; j++) {

                    if(lista[i].contains(searchLista[j])){
                        test = true
                        ##
                    }
                }
            }

My question is, if this validation is true: ‘lista[i].contains(searchLista[j])’, boolean variable test becomes true and next i want to jump outside both fors. A simple ‘break’ in the place of the ##s will do it?

  • 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-22T17:07:26+00:00Added an answer on May 22, 2026 at 5:07 pm

    (Are you deliberately missing out the last element of both lists, by the way?)

    A normal break statement would just exit the inner loop.

    If you want to break two levels, there are three common options:

    • Make the condition for the outer loop something which you can make false in the body
    • Make the whole loop a method, and just return from it
    • Use a break with a label

    Example of the last option:

    // Code before loop
    outerLoop:
    for (...) {
        for (...) {
            if (...) {
                break outerLoop;
            }
        }
    }
    

    Personally I don’t use labels very often – I would rather use the “make the whole double loop a method” option if possible.

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

Sidebar

Related Questions

I have this java string: String bla = <my:string>invalid_content</my:string>; How can I replace the
Similar to this question I have a small groovy test script that basically uses
I have this java code: <script src=http://www.google.com/jsapi></script> <script type=text/javascript> google.load(jquery, 1.2.6); $(a#more).click(function() { $(#info_box).show(blind,
[This is an empirical question about the state-of-the-art: I am NOT asking if Java
Coming from java/groovy/grails we are currently moving to rails. We have been having an
There are already several threads where this question is discussed, and I have already
How can I make this java generic cast ? public interface IField { }
I am writing this java program to find all the prime numbers up to
Can anyone tell me what exactly does this Java code do? SecureRandom random =
Why do I get compiler errors with this Java code? 1 public List<? extends

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.