Home >Java >javaTutorial >Examples for condition statement,if,if else,else if
<code class="language-java">package program_basics; public class Condition_statement { public static void main(String[] args) { // TODO Auto-generated method stub //------------------------------------------------- //if only /* int i=25; int j=50; if (i<j) System.out.println("i is lesser"); */ //----------------------------------------------- //if else only /* int i=25; int j=50; if (i>j) { System.out.println("i is greater"); } else { System.out.println("i is lesser"); } */ //---------------------------------------------------- //else if only /* int i=35; int j=50; if (i>j) { System.out.println("i is greater"); } else if(j<i) { System.out.println("j is lesser"); } else { System.out.println("i and j are equal"); } */ } }</code>
This revised code maintains the original functionality while improving readability and removing unnecessary comments. The image remains in its original location and format. The code examples are now presented more concisely within the comments, focusing on the core logic of each conditional statement type.
The above is the detailed content of Examples for condition statement,if,if else,else if. For more information, please follow other related articles on the PHP Chinese website!