About 1,390,000 results
Open links in new tab
  1. Java Nested if - GeeksforGeeks

    Jan 11, 2025 · Example 1: The below Java program demonstrates the use of nested if statements to check multiple conditions and execute a block of code when both conditions are true. Explaination: In the above example, one if condition is placed inside another. If both conditions are true, it prints GeeksforGeeks.

  2. java - How to use a for loop with an if-else statement - Stack Overflow

    The solution to this problem is moving the return to the end of the statement to actually return the fully calculated value. Well we can even skip the for loop by calculating the value directly: else if(score >= 63 && score <= 94) { return 0.7 + (0.1 * (score - 62)); }

  3. Nested Loop in Java (With Examples) - Programiz

    If a loop exists inside the body of another loop, it's called a nested loop. Here's an example of the nested for loop. // outer loop for (int i = 1; i <= 5; ++i) { // codes // inner loop for(int j = 1; j <=2; ++j) { // codes } ..

  4. Java Nested for loop ( with if statement in inner for loop )

    Oct 20, 2018 · //set initial value of nOdd. if ( n%2 == 0 ){ nOdd = false; System.out.println(nOdd); else { nOdd = true ; System.out.println(nOdd); //populate array of boxes, set color and position for each. for(int c= 0; c<box.length;c++){ for(int r= 0; r<box.length;r++){ box[c][r] = new TextField("x"); //System.out.println(box[c][r]); if (nOdd == true){

  5. Decision Making in Java (if, if-else, switch, break, continue, jump)

    Apr 16, 2025 · nested-if Statement Execution Flow. The below diagram demonstrates the flow chart of an “nested-if Statement execution flow” in programming. Example: The below Java program demonstrates the use of nested if statements to check multiple conditions.

  6. Java Nested Loops with Examples - GeeksforGeeks

    Jan 11, 2024 · Below are some examples to demonstrate the use of Nested Loops: Example 1: Below program uses a nested for loop to print a 2D matrix. Example 2: Below program uses a nested for loop to print all prime factors of a number.

  7. Java Nested Loops - W3Schools

    It is also possible to place a loop inside another loop. This is called a nested loop. The "inner loop" will be executed one time for each iteration of the "outer loop": Track your progress - it's free!

  8. Nested if-else statement in Java (with examples) - codedamn

    Oct 18, 2022 · In this article, we’ll learn how to implement nested if-else statement in java. Before moving to nested if-else statements. Let’s revise what if else statements are. An if-else statement is a conditional statement that decides the execution path based on whether the condition is …

  9. Java 8 - Nested if inside a loop - Stack Overflow

    Nov 2, 2017 · The only thing I would improve is to use a switch-statement: switch(category){ case Category.A: // do Something break; } As mentionend by luk2302 this will only work if Category is an enum.

  10. Java Nested For Loop – Syntax, Examples, Best Practices

    This tutorial covers various aspects of nested for loops in Java, including: The concept and structure of nested for loops. Syntax of a nested for loop. Example programs with detailed explanations and outputs. Best practices and tips for using nested loops effectively.

Refresh