- Exercise-1: Echoing words in Java
- Exercise 2: Inputting and Echoing integer and string entered by user
- Exercise-3: How to use If Statement in Java Programming
- Exercise-4: How to Use If-ElseStatement in Java Programming
- Exercise-5: Using Multi If and Else Statement in Java Programming
- Exercise-6: Write a program which will represent the entire relational operators in Java Programming.
- Exercise-7: Write a program to demonstrate the logical operators in Java.
- Excercise-8: Write a Program Using Conditional Operator.
- Exercise-9: Java Exercise of IF and SWITCH
- Exercise-10: Java Exercise of While, Do-While and For Loop
- Exercise-11: Java Misc. Excercise(1-10)
- Exercise-11: Java Misc. Exercise(11-19)
- Exercise-11: Java Misc. Exercise(20-25)
Showing posts with label if else. Show all posts
Showing posts with label if else. Show all posts
Friday, February 8, 2013
Excercise between W1 and W3
Week-3: 3.2 : IF else
If else:
Instead of using two IF Statements, you can use an IF … ELSE Statement instead. Here's
the structure of an IF … ELSE statement:
if ( condition_to_test ) {
}
else {
}
The first line starts with if, followed by the condition you want to test for. This goes
between two round brackets. Again, curly brackets are used to section off the different
choices. The second choice goes after the word else and between its own curly brackets.
Here's our code again that checks a user's age:
Instead of using two IF Statements, you can use an IF … ELSE Statement instead. Here's
the structure of an IF … ELSE statement:
if ( condition_to_test ) {
}
else {
}
The first line starts with if, followed by the condition you want to test for. This goes
between two round brackets. Again, curly brackets are used to section off the different
choices. The second choice goes after the word else and between its own curly brackets.
Here's our code again that checks a user's age:
Visit for Details
Subscribe to:
Posts (Atom)