Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Java Programming/Statements/if

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

The ... statement is used to conditionally execute one of two statements, depending on the result of a boolean condition. Example: (list == null) { {{Java://|this block of statements executes if the condition is true } { {{Java://|this block of statements executes if the condition is false } An statement has two forms: () and () Use the second form if you have different statements to execute if the is true or if it is false. Use the first if you only wish to execute if the condition is true and you do not wish to execute alternate statements if the condition is false. The following example calls two methods, f() and f(), stores the results, then uses an statement to test if x is less than y and if it is, the body will swap the values. The end result is x always contains the larger result and y always contains the smaller result. x = f(); y = y(); ( x < y ) { z = x; x = y; y = z; }