how execute if condition several times without break inside for loop in java?
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
|
show 2 more comments
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
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 afor
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 anif
and it (and its containedfor
loop) form the single statement of the outerfor
loop. So the five lines following the initialfor
form its body.
– dave
Nov 25 '18 at 1:30
|
show 2 more comments
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
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
java
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 afor
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 anif
and it (and its containedfor
loop) form the single statement of the outerfor
loop. So the five lines following the initialfor
form its body.
– dave
Nov 25 '18 at 1:30
|
show 2 more comments
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 afor
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 anif
and it (and its containedfor
loop) form the single statement of the outerfor
loop. So the five lines following the initialfor
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
|
show 2 more comments
1 Answer
1
active
oldest
votes
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
add a comment |
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
add a comment |
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
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
answered Nov 29 '18 at 10:42
fpezzinifpezzini
177111
177111
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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 containedfor
loop) form the single statement of the outerfor
loop. So the five lines following the initialfor
form its body.– dave
Nov 25 '18 at 1:30