About 2,130,000 results
Open links in new tab
  1. Java If ... Else - W3Schools

    Use the if statement to specify a block of Java code to be executed if a condition is true. Syntax if ( condition ) { // block of code to be executed if the condition is true }

  2. Java if statement - GeeksforGeeks

    Nov 22, 2024 · The if-else statement in Java is a powerful decision-making tool used to control the program's flow based on conditions. It executes one block of code if a condition is true and another block if the condition is false. In this article, we will learn Java if-else statement with examples. Example: [GF

  3. java - Calling a method from within an if/if else statement - Stack ...

    Apr 26, 2013 · Is it possible to call a method within an if statement, and then a separate method in an if else statement? I have created a scanner than reads keyboard input, and based on the option the user gives, a different method will be called.

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

    Apr 16, 2025 · It is used to decide whether a certain statement or block of statements will be executed or not i.e. if a certain condition is true then a block of statements is executed otherwise not. Syntax:

  5. java - A Return inside and outside an If Statement - Stack Overflow

    Aug 16, 2013 · If there is a return statement inside an if statement, inside a method (in the Java language), but I add another at the end as a catch-all and to avoid the error, are both return values going to be fired one after the other if the if statement is true? An example: if( 5 > number) { return 5; return 0;

  6. java - If statements in the methods or in the main ... - Stack Overflow

    Jul 28, 2016 · You're correct that it won't scale nicely if you have dozens of type checks in the main() method. Instead, a better approach would be to have a util method, or even a class, which can do these checks. This could be called from main(). –

  7. The if-then and if-then-else Statements (The Java™ Tutorials - Oracle

    The if-then statement is the most basic of all the control flow statements. It tells your program to execute a certain section of code only if a particular test evaluates to true. For example, the Bicycle class could allow the brakes to decrease the bicycle's speed only if …

  8. Java if...else (With Examples) - Programiz

    The Java if...else statement is used to run a block of code under a certain condition and another block of code under another condition. In this tutorial, we will learn about if...else statements in Java with the help of examples.

  9. Conditionals - The If Statement - Java Made Easy!

    An if statement is used in Java when you want code to happen whenever a condition exists. We will look at how to create one and how to use them.

  10. Using If statements in Java with examples | Code Underscored

    Jan 13, 2022 · The most straightforward basic decision-making statement in Java is the if statement. It is used to determine if a statement or a block of statements will be executed or not, i.e., if a condition is true, a block of statements will be executed, otherwise not. If statement syntax: The if statement in action. The if block is where control resides.

  11. Some results have been removed