how execute if condition several times without break inside for loop in java?












0















In the following code I want to execute the if condition inside the outer for loop several times, but in the following code it only executes once and executes the steps after it. binaryHashResult is an array and innerNode is a List. I want to check if all values in array exist in list.



for (int j = 0; j < binaryHashResult.length; j++) 
if (innerNode[binaryHashResult[j]] == 1.0)
for (int h = 0; h < m.children.size(); h++) {
BloomFilterIndex.BFINode<Integer> s=m.children.get(h);
searchencryptedNode(binaryHashResult, e, k, s);
}









share|improve this question




















  • 2





    How do you know it is only executed once? Did you use a debugger?

    – Michael Butscher
    Nov 25 '18 at 1:18






  • 2





    @W.Ambrozic a for loop does not require braces, although it's generally a good practice to do so.

    – dave
    Nov 25 '18 at 1:24











  • Please show a Minimal, Complete, and Verifiable example... If it only execute once, then are you ever changing the values in the array? What are the values?

    – cricket_007
    Nov 25 '18 at 1:27











  • Might want to check out some debugging tips too ericlippert.com/2014/03/05/how-to-debug-small-programs

    – cricket_007
    Nov 25 '18 at 1:29






  • 1





    @W.Ambrozic Not quite. It's not one line but one statement. The next statement is an if and it (and its contained for loop) form the single statement of the outer for loop. So the five lines following the initial for form its body.

    – dave
    Nov 25 '18 at 1:30


















0















In the following code I want to execute the if condition inside the outer for loop several times, but in the following code it only executes once and executes the steps after it. binaryHashResult is an array and innerNode is a List. I want to check if all values in array exist in list.



for (int j = 0; j < binaryHashResult.length; j++) 
if (innerNode[binaryHashResult[j]] == 1.0)
for (int h = 0; h < m.children.size(); h++) {
BloomFilterIndex.BFINode<Integer> s=m.children.get(h);
searchencryptedNode(binaryHashResult, e, k, s);
}









share|improve this question




















  • 2





    How do you know it is only executed once? Did you use a debugger?

    – Michael Butscher
    Nov 25 '18 at 1:18






  • 2





    @W.Ambrozic a for loop does not require braces, although it's generally a good practice to do so.

    – dave
    Nov 25 '18 at 1:24











  • Please show a Minimal, Complete, and Verifiable example... If it only execute once, then are you ever changing the values in the array? What are the values?

    – cricket_007
    Nov 25 '18 at 1:27











  • Might want to check out some debugging tips too ericlippert.com/2014/03/05/how-to-debug-small-programs

    – cricket_007
    Nov 25 '18 at 1:29






  • 1





    @W.Ambrozic Not quite. It's not one line but one statement. The next statement is an if and it (and its contained for loop) form the single statement of the outer for loop. So the five lines following the initial for form its body.

    – dave
    Nov 25 '18 at 1:30
















0












0








0








In the following code I want to execute the if condition inside the outer for loop several times, but in the following code it only executes once and executes the steps after it. binaryHashResult is an array and innerNode is a List. I want to check if all values in array exist in list.



for (int j = 0; j < binaryHashResult.length; j++) 
if (innerNode[binaryHashResult[j]] == 1.0)
for (int h = 0; h < m.children.size(); h++) {
BloomFilterIndex.BFINode<Integer> s=m.children.get(h);
searchencryptedNode(binaryHashResult, e, k, s);
}









share|improve this question
















In the following code I want to execute the if condition inside the outer for loop several times, but in the following code it only executes once and executes the steps after it. binaryHashResult is an array and innerNode is a List. I want to check if all values in array exist in list.



for (int j = 0; j < binaryHashResult.length; j++) 
if (innerNode[binaryHashResult[j]] == 1.0)
for (int h = 0; h < m.children.size(); h++) {
BloomFilterIndex.BFINode<Integer> s=m.children.get(h);
searchencryptedNode(binaryHashResult, e, k, s);
}






java






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 25 '18 at 1:26









dave

8,48752850




8,48752850










asked Nov 25 '18 at 1:13









user9860564user9860564

194




194








  • 2





    How do you know it is only executed once? Did you use a debugger?

    – Michael Butscher
    Nov 25 '18 at 1:18






  • 2





    @W.Ambrozic a for loop does not require braces, although it's generally a good practice to do so.

    – dave
    Nov 25 '18 at 1:24











  • Please show a Minimal, Complete, and Verifiable example... If it only execute once, then are you ever changing the values in the array? What are the values?

    – cricket_007
    Nov 25 '18 at 1:27











  • Might want to check out some debugging tips too ericlippert.com/2014/03/05/how-to-debug-small-programs

    – cricket_007
    Nov 25 '18 at 1:29






  • 1





    @W.Ambrozic Not quite. It's not one line but one statement. The next statement is an if and it (and its contained for loop) form the single statement of the outer for loop. So the five lines following the initial for form its body.

    – dave
    Nov 25 '18 at 1:30
















  • 2





    How do you know it is only executed once? Did you use a debugger?

    – Michael Butscher
    Nov 25 '18 at 1:18






  • 2





    @W.Ambrozic a for loop does not require braces, although it's generally a good practice to do so.

    – dave
    Nov 25 '18 at 1:24











  • Please show a Minimal, Complete, and Verifiable example... If it only execute once, then are you ever changing the values in the array? What are the values?

    – cricket_007
    Nov 25 '18 at 1:27











  • Might want to check out some debugging tips too ericlippert.com/2014/03/05/how-to-debug-small-programs

    – cricket_007
    Nov 25 '18 at 1:29






  • 1





    @W.Ambrozic Not quite. It's not one line but one statement. The next statement is an if and it (and its contained for loop) form the single statement of the outer for loop. So the five lines following the initial for form its body.

    – dave
    Nov 25 '18 at 1:30










2




2





How do you know it is only executed once? Did you use a debugger?

– Michael Butscher
Nov 25 '18 at 1:18





How do you know it is only executed once? Did you use a debugger?

– Michael Butscher
Nov 25 '18 at 1:18




2




2





@W.Ambrozic a for loop does not require braces, although it's generally a good practice to do so.

– dave
Nov 25 '18 at 1:24





@W.Ambrozic a for loop does not require braces, although it's generally a good practice to do so.

– dave
Nov 25 '18 at 1:24













Please show a Minimal, Complete, and Verifiable example... If it only execute once, then are you ever changing the values in the array? What are the values?

– cricket_007
Nov 25 '18 at 1:27





Please show a Minimal, Complete, and Verifiable example... If it only execute once, then are you ever changing the values in the array? What are the values?

– cricket_007
Nov 25 '18 at 1:27













Might want to check out some debugging tips too ericlippert.com/2014/03/05/how-to-debug-small-programs

– cricket_007
Nov 25 '18 at 1:29





Might want to check out some debugging tips too ericlippert.com/2014/03/05/how-to-debug-small-programs

– cricket_007
Nov 25 '18 at 1:29




1




1





@W.Ambrozic Not quite. It's not one line but one statement. The next statement is an if and it (and its contained for loop) form the single statement of the outer for loop. So the five lines following the initial for form its body.

– dave
Nov 25 '18 at 1:30







@W.Ambrozic Not quite. It's not one line but one statement. The next statement is an if and it (and its contained for loop) form the single statement of the outer for loop. So the five lines following the initial for form its body.

– dave
Nov 25 '18 at 1:30














1 Answer
1






active

oldest

votes


















0














Always wrap blocks of code with {} regardless if the block has only one line.



for (int j = 0; j < binaryHashResult.length; j++) 
if (innerNode[binaryHashResult[j]] == 1.0) {
for (int h = 0; h < m.children.size(); h++) {
BloomFilterIndex.BFINode<Integer> s=m.children.get(h);
searchencryptedNode(binaryHashResult, e, k, s);
} // closes inner for loop
} // closes if
} // closes outer for loop





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53463855%2fhow-execute-if-condition-several-times-without-break-inside-for-loop-in-java%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Always wrap blocks of code with {} regardless if the block has only one line.



    for (int j = 0; j < binaryHashResult.length; j++) 
    if (innerNode[binaryHashResult[j]] == 1.0) {
    for (int h = 0; h < m.children.size(); h++) {
    BloomFilterIndex.BFINode<Integer> s=m.children.get(h);
    searchencryptedNode(binaryHashResult, e, k, s);
    } // closes inner for loop
    } // closes if
    } // closes outer for loop





    share|improve this answer




























      0














      Always wrap blocks of code with {} regardless if the block has only one line.



      for (int j = 0; j < binaryHashResult.length; j++) 
      if (innerNode[binaryHashResult[j]] == 1.0) {
      for (int h = 0; h < m.children.size(); h++) {
      BloomFilterIndex.BFINode<Integer> s=m.children.get(h);
      searchencryptedNode(binaryHashResult, e, k, s);
      } // closes inner for loop
      } // closes if
      } // closes outer for loop





      share|improve this answer


























        0












        0








        0







        Always wrap blocks of code with {} regardless if the block has only one line.



        for (int j = 0; j < binaryHashResult.length; j++) 
        if (innerNode[binaryHashResult[j]] == 1.0) {
        for (int h = 0; h < m.children.size(); h++) {
        BloomFilterIndex.BFINode<Integer> s=m.children.get(h);
        searchencryptedNode(binaryHashResult, e, k, s);
        } // closes inner for loop
        } // closes if
        } // closes outer for loop





        share|improve this answer













        Always wrap blocks of code with {} regardless if the block has only one line.



        for (int j = 0; j < binaryHashResult.length; j++) 
        if (innerNode[binaryHashResult[j]] == 1.0) {
        for (int h = 0; h < m.children.size(); h++) {
        BloomFilterIndex.BFINode<Integer> s=m.children.get(h);
        searchencryptedNode(binaryHashResult, e, k, s);
        } // closes inner for loop
        } // closes if
        } // closes outer for loop






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 29 '18 at 10:42









        fpezzinifpezzini

        177111




        177111






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53463855%2fhow-execute-if-condition-several-times-without-break-inside-for-loop-in-java%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Calculate evaluation metrics using cross_val_predict sklearn

            Insert data from modal to MySQL (multiple modal on website)