Conditional statements in java | if else | switch statements | else if | Simple If | Java Tutorial

preview_player
Показать описание
"Conditional statements in java || if else || switch statements || else if || Simple If || Java Tutorial for Beginners | Learn Java | Parnika Tutorials

#conditionalstatemnts #elseif #ifelse #switchstatements #simpleif #javastatements #javafeatures #featuresjava #java #javafullcourse #javatutorials #javaforbeginners #javalanguage #learnjava #javacompletecourse #javaprogramming #javatutorialforbeginners #parnikatutorials #javacourse

00:00 - Introduction
00:28- Simple if
10:38 - Implementation of simple if
15:26 - If else in java
22:15 - Checking given number is even or odd
26:09 - Else if ladder in java
35:19 - Verifying given number is positive or negative
38:06 - Switch statement in java
47:14 - Implementation of switch statement

previous video- #10 INPUT AND OUTPUT STREAMS IN JAVA | INPUT AND OUTPUT IN JAVA | JAVA FULL COURSE

Social media Links:
To get the regular updates:

Playlists:

if statement is the most simple decision-making statement. 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 statement is executed otherwise not
The if statement executes a certain section of code if the test expression is evaluated to true. However, if the test expression is evaluated to false, it does nothing.

In this case, we can use an optional else block. Statements inside the body of else block are executed if the test expression is evaluated to false. This is known as the if-...else statement in Java.

The syntax of the if...else statement is:

if (condition) {
// codes in if block
}
else {
// codes in else block
}
In Java, we have an if...else...if ladder, that can be used to execute one block of code among multiple other blocks.

if (condition1) {
// codes
}
else if(condition2) {
// codes
}
else if (condition3) {
// codes
}
.
.
else {
// codes
}
Here, if statements are executed from the top towards the bottom. When the test condition is true, codes inside the body of that if block is executed. And, program control jumps outside the if...else...if ladder.

If all test expressions are false, codes inside the body of else are executed.
The switch statement allows us to execute a block of code among many alternatives.

The syntax of the switch statement in Java is:

switch (expression) {

case value1:
// code
break;

case value2:
// code
break;

...
...

default:
// default statements
}

How does the switch-case statement work?

The expression is evaluated once and compared with the values of each case.

If expression matches with value1, the code of case value1 are executed. Similarly, the code of case value2 is executed if expression matches with value2.
If there is no match, the code of the default case is executed.
Рекомендации по теме
Комментарии
Автор

Very nice Explanation sir ..thank you sir 💯🥇

prasadsabbavarapu
Автор

Very good and clear cut explaination..I'm new to your channel ..hoping for more vedios with more real time examples..thanks for sharing your knowledge..

sowmyakondeti
join shbcf.ru