Java if-else statement Example

Java if-else statement tests several conditions and executes the one that returns true.

Programming is Java is fun.I love doing this.Today am going to show you how to use if-else statement in java.


How does Java if-else statement work?

Java if-else statement tests several conditions and executes the one that returns true.If none of the condition returns true,the code in else condition is execute:

There are various types of if-else statements in java

1.if statement
2.if-else statement
3.nested if statement
4.if-else ladder statement.

Java if-else statement code example:




 public class JavaStatement{   
 /**   
 * @param args the command line arguments   
 */   
 public static void main(String[] args) {   
 // TODO code application logic here   
 int results=70;  
  if(results>=90)  
  {  
     System.out.println("Your Grade is  A");   
 }  
  else if (results>=80&& results<90)  
   System.out.println("Your Grade is  B");  
    else if (results>=70&& results<80)  
     System.out.println("Your Grade is C");   
    else if (results>=60&& results<70)  
     System.out.println("Your Grade is D");  
    else{  
     System.out.println("Your Grade is E");  
    }    
 }   
 }  

Above Code Output:


 Your Grade is C  


COMMENTS

Name

android android Apps android emulators antivirus blogger bluestack Break Statement in Java constructors download downloader drivers emulators java java control statements java do-while loop java for loop java infinitive do-while loop java system methods java tutorials Java While Loop java.awt java.swing javalookandfeel javascript JButton JCheckBox JColorChooser JComboBox JDialog JFileChooser JFrame JLayeredPane JList JMenuBar joomla JOptionPane JPanel JPasswordField JPopupMenu JProgressBar JRadioButton JScrollBar JSlider JSpinner JTabbedPane JTable JTextArea JTextField JToolBar mysql php plugins Polymorphism setToolTiptext skype for windows software swing class themes Visual Studio Code WeChat whatsapp wordpress
false
ltr
item
Java Codes: Java if-else statement Example
Java if-else statement Example
Java if-else statement tests several conditions and executes the one that returns true.
Java Codes
http://www.download-all.net/2017/01/java-if-else-statement-example.html
http://www.download-all.net/
http://www.download-all.net/
http://www.download-all.net/2017/01/java-if-else-statement-example.html
true
7826648292785071009
UTF-8
Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy