If Statement in Java Programming Language – Decision Making Statements in Java – Java Programming


Click the bell icon to get latest videos from Ekeeda Hello friends in last video we have seen something called as Beatriz operators ok now today we are going to see something called as decision-making statements now the name itself says that some statement which allows me to make a decisions ok normally we are Java program is having some sequence of instructions right now within that particular program if I want to make a certain decisions and I want to change the flow I want to skip out some statements or I want to purposefully execute some statements so in that case you can go for decision making statements so Java has provided us mainly our decision making statements which I allow me to alter the flow of the normal execution of the program ok and one one of it is a if statement ok we also have a switch statement for it so in this video we are going to check it out what is if statement all about [Music] let’s have a look to the decision-making statements basically this desiccant is decision making statements controls the structure allows us to change the order of how the statement in our program are executed that means normally if I if I don’t have any decision-making statement then my program will stop execute some talk to water okay so basically if I want to make certain decision and based on that decision I have to decide whether to execute a certain portion of a program or not okay so basically it is like altering the flow of the program so that is being done by using decision making statement so in decision making statement we are having which allows us to spill our select specific section of the code to be executed then it also have the reputation control structure which we will see in coming videos then it allows us to execute specific section of the code number of times that is also something called as looping statement which we will see soon maybe in next video so we are having our different types of decision-making statements so one of it is if statement that we are having if-else statement then if else if statement then we are having nested if then we are having lied at if statement which we will see soon in the coming videos so to talk in this video we are going to check it out if statement so what is each statement if statement is a statement which takes execute of law of code based on condition which we are specifying inside the paranthesis okay so basically if statement is having syntax like this it is if then we have a parenthesis and within the parenthesis we have to provide the condition now you have to make sure that this we should return mean boolean value that is true or false okay so we can make use of relational operators logical operators extensively in this particular expression so boolean expression now if the condition which are specified within the parentheses is true then block of code following the if statement will get executed okay so if I am having n number of statements then I have to provide that inside curly braces okay but if I am having only single statement to be executed then I don’t have to really use curly braces okay so this is a syntax of if statement so if you are having this condition true then only it will execute the statements which is specified inside curly braces okay so we can have an example for it here I am having class condition here I’m having a method main method now here I have taken one variable int grade and which is assigned with a value 68 now I have a condition that if my grade is greater than 16 then I am going to congratulate the person and I am going to show some message that you have passed okay so here I have written the condition by making use of relational operators so if grade so you have to bright it inside the parentheses so great greater than 60 okay then I am printing a message by using system dot out dot println statement that is congratulation and then you pass okay so what is the value inside grade variable the variable is having 68 and 68 is greater than 60 yes so this particular condition will give me true result you

Leave a Reply

Your email address will not be published. Required fields are marked *