{"id":76494,"date":"2020-02-17T16:18:59","date_gmt":"2020-02-17T10:48:59","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=76494"},"modified":"2020-02-17T16:18:59","modified_gmt":"2020-02-17T10:48:59","slug":"decision-making-in-java","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/decision-making-in-java\/","title":{"rendered":"Decision Making in Java &#8211; Explore the types of Statements with Syntax"},"content":{"rendered":"<p>Each programming language provides some constructs which are necessary for decision making and also for the flow of control of a program. Decision making is really important when we get trapped in some dilemma.<\/p>\n<p>Java language provides the facility of decision-making with the use of selection statements, which depend on expression&#8217;s truth value. If the condition is true, control goes into a particular block of code, and if it is false, then the control goes to another block of the program.<\/p>\n<p>In this article, we will cover each and every decision-making statement that is supported by Java. Before starting our Java Tutorial on Decision Making in Java, you first need to take a quick revision of <em><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/data-types-in-java\/\">Data types in Java<\/a><\/strong><\/em>.<\/p>\n<h3>Decision Making in Java<\/h3>\n<p>Decision making in Java is done with the help of selection statements or selection constructs. The selection construct means the flow of execution of statement(s) depends upon a test-condition.<\/p>\n<p>If a condition is fulfilled, a course-of-action (a set of statements) is followed otherwise, another course-of-action (a different set of statements) is followed. This selection construct is also called the decision construct because it helps in decision-making about which set-of-statements are to be executed.<\/p>\n<p><em>The following figure explains the selection or decision construct:<\/em><\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/Selection-Construct-in-Java.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-76657\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/Selection-Construct-in-Java.png\" alt=\"Selection Construct in Java\" width=\"600\" height=\"366\" \/><\/a><\/p>\n<h3>Types of Decision Making Statements in Java<\/h3>\n<p>Java provides two types of decision-making statements:<\/p>\n<ul>\n<li><em><strong>if<\/strong> statement <\/em><\/li>\n<li><em><strong>switch<\/strong> statement<\/em><\/li>\n<\/ul>\n<p>The <strong>if<\/strong> statement can be further divided into many categories that we will cover in this article. We will also discuss the jump statements in Java, which are <strong>break<\/strong> and <strong>continue<\/strong>. Let\u2019s start talking about each decision statement with syntax and examples.<\/p>\n<h4>1. The if statement in Java<\/h4>\n<p>An <strong>if<\/strong> statement checks a particular condition; if the condition evaluates to true, it will execute a statement or a set of statements. Otherwise, if the condition is false, it will ignore that statement or set of statements. The test expression of if must be of boolean type.<\/p>\n<p><strong>The general form or syntax of the if statement is:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">if( test-condition)\n{\n  \/\/statement(s);\n}<\/pre>\n<p>Here, the statement can be a single statement, a compound statement or even an empty statement.<\/p>\n<p>If we do not provide the curly braces \u2018{\u2018 and }\u2019 after the <strong>if statement<\/strong> then by default it will consider the immediate single statement after the if statement.<\/p>\n<p><strong>For example,<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">if( test-condition)\n   \/\/statement1;\n   \/\/statement2;<\/pre>\n<p>In the above code, if the condition is true then the if statement considers the only statement1 to be inside the if-block.<\/p>\n<p><em>The following figure shows the if construct of Java.<\/em><\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/Working-of-If-in-Java.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-76658\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/Working-of-If-in-Java.png\" alt=\"If Statement Operation\" width=\"393\" height=\"489\" \/><\/a><\/p>\n<p><strong>Code to illustrate the if statement:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.DecisionMakingDemo;\n\/\/Java program to illustrate If statement\npublic class IfStatementDemo\n{\n  public static void main(String args[])\n  {\n    int i = 5;\n\n    if (i % 2 == 0)\n      System.out.println(\"5 is divisible by 2\");\n    \/\/ This statement will be executed\n    \/\/ as if considers one statement by default\n    System.out.println(\"I am Not in if block\");\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">I am Not in if block<\/div>\n<p><em><strong>Caution!!<\/strong> Do not put a semicolon after the test condition in the if statement. If you do so, the if statement will end there. The block of statements following the if statement will no longer be the part of if in such cases.<\/em><\/p>\n<h4>2. The if-else statement in Java<\/h4>\n<p>The if statement only allows us to execute a set of statements if a condition or expression is true. What if there is another course of action to be followed if the expression evaluates to false? So, there comes another form of <strong>if<\/strong> that allows for this kind of either-or condition by providing an <strong>else<\/strong> clause.<\/p>\n<p>It is called an if-else statement in which we can use the else statement with an if statement so that we can execute a block of code when the test condition is false.<\/p>\n<p><strong>The general form or syntax of the <em>if-else<\/em> statement is:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">if( test-condition)\n{\n  \/\/statement(s);\n}\nelse\n{\n  \/\/statement(s);\n}<\/pre>\n<p><em>Note: Remember, in an if-else statement, only the code associated with the <strong>if<\/strong> or the code associated with <strong>else<\/strong> executes, both can never execute together.<\/em><\/p>\n<p><em>The following figure shows the if-else construct of Java.<\/em><\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/If-else-Statement-in-Java.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-76659\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/If-else-Statement-in-Java.png\" alt=\"if-else statement operation\" width=\"499\" height=\"489\" \/><\/a><\/p>\n<p><strong>Code to illustrate the if-else statement:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.DecisionMakingDemo;\n\/\/Java program to illustrate If-else statement\npublic class IfElseStatementDemo\n{\n  public static void main(String args[])\n  {\n    int i = 5;\n\n    if (i % 2 == 0)\n      System.out.println(\"5 is divisible by 2\");\n\n    else\n      System.out.println(\"5 is not divisible by 2\");\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">5 is not divisible by 2<\/div>\n<h4>3. The Nested-Ifs statements in Java<\/h4>\n<p>A nested if is an if statement that has another if in its if\u2019s body or in its else\u2019s body. As Java allows nested if statements, we can place an if or else-if statement inside another if statement.<\/p>\n<p><strong>The general form or syntax of the Nested if statement can either be in 3 forms:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">if(expression1) {\n  :\n      if(expression2)\n  statement1;\n      else\n  statement2 ;\n      :\n}\nelse\n  body of else;<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">if(expression1) {\n  body of if ;\n  else { :\n    if(expression2)\n    statement1;\n    else\n    statement2;\n  }<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">if(expression1) {\n  :\n      if(expression2)\n   statement1;\n      else\n   statement2 ;\n      :\n}\nelse {\n   if(expression3)\n    statement3;\n      else\n    statement4;\n}<\/pre>\n<p><em>The following figure shows the Nested if construct of Java.<\/em><\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/Nested-if-in-Java.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-76660\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/Nested-if-in-Java.png\" alt=\"Nested if in Java\" width=\"714\" height=\"430\" \/><\/a><\/p>\n<p><strong>Code to illustrate the Nested if statement:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.DecisionMakingDemo;\n\/\/Java program to illustrate Nested If statement\npublic class NestedIfDemo\n{\n  public static void main(String args[])\n  {\n    int age = 18, weight = 50 ;\n\n    if (age &gt;= 18)\n    {\n         System.out.println(\"You are eligible to vote\");\n         if (weight &gt;= 50)\n        System.out.println(\"You are eligible to vote and donate blood\");\n         else\n        System.out.println(\"you are not eligible to donate blood\") ;\n    }\nelse\n        System.out.println(\"you are not eligible for both!!\") ;\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">You are eligible to vote<br \/>\nYou are eligible to vote and donate blood<\/div>\n<h4>4. The if-else-if Ladder Statement of Java<\/h4>\n<p>The if-else-if ladder is a very common programming constructs in Java, which is also called the if-else-if staircase because of its appearance. We can use many if-else-if statements in our program.<\/p>\n<p><strong>The general form or syntax of the if-else-if ladder statement is:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">if( expression1)\n  statement1 ;\nelse if(expression2)\n  statement2;\n  .\n  .\nelse\n  statement3;<\/pre>\n<p><em>The following figure shows the if-else-if ladder of Java.<\/em><\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/If-else-if-Ladder-Statement-in-Java.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-76664\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/If-else-if-Ladder-Statement-in-Java.png\" alt=\"If else if statement\" width=\"600\" height=\"600\" \/><\/a><strong>Code to illustrate the if-else-if ladder statement:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.DecisionMakingDemo;\n\/\/Java program to illustrate Nested If statement\npublic class IfElseIfDemo\n{\n  public static void main(String[] args)\n  {\n    int number=-13;\n\n    if(number&gt;0) {\n      System.out.println(\"The number is POSITIVE\");\n    }\n    else if(number&lt;0) {\n      System.out.println(\"The number is NEGATIVE\");\n    }\n    else {\n      System.out.println(\"The number is equal toZERO\");\n    }\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">The number is NEGATIVE<\/div>\n<h4>5. The switch statement of Java<\/h4>\n<p>A <strong>switch<\/strong> statement is a multiple-branch statement in Java. The switch statement successively checks the value of an expression with a list of integer or character constants.<\/p>\n<p>The data type of expression in a switch must be byte, char, short or int. When a match is found, the statements associated with that constant are executed.<\/p>\n<p><strong>The general form or syntax of the switch statement is:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">switch (expression)\n{\n    case value1:\n    statement1;\n    break;\n\n    case value2:\n    statement2;\n    break;\n    .\n    .\n    case valueN:\n    statementN;\n    break;\n\n    default:\n    statementDefault;\n}<\/pre>\n<p>The switch statement evaluates the expression and matches the values against the constant values which are specified in the <strong>case<\/strong> statements.<\/p>\n<p>When a match is found, the statement associated with that case is executed until it encounters a <strong>break<\/strong> statement or else the switch statement ends. When no match is found, the <strong>default<\/strong> statement gets executed.<\/p>\n<p>In the absence of <strong>break<\/strong>, the control flow moves to the next case below the matching case and this is called <strong>fall through<\/strong>.<\/p>\n<p><em><strong>Note:<\/strong> The <strong>default<\/strong> statement is optional and if it is missing, no action takes place if all matches fail.<\/em><\/p>\n<p><em>The following figure shows the switch case of Java.<\/em><\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/Switch-Case-in-Java.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-76663\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/Switch-Case-in-Java.png\" alt=\"Switch-Case-in-Java\" width=\"583\" height=\"621\" \/><\/a><\/p>\n<p><strong>Code to illustrate the switch statement:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.DecisionMakingDemo;\n\/\/Java program to illustrate switch statement\npublic class SwitchCaseDemo\n{\n  public static void main(String[] args)\n  {\n    int day = 5;\n    switch(day) {\n    case 0:\n      System.out.println(\"Sunday\");\nbreak;\n    case 1:\n      System.out.println(\"Monday\");\nbreak;\n    case 2:\n      System.out.println(\"Tuesday\");\nbreak;\n    case 3:\n      System.out.println(\"Wednesday\");\nbreak;\n    case 4:\n      System.out.println(\"Thursday\");\nbreak;\n    case 5:\n      System.out.println(\"Friday\");\nbreak;\n    case 6:\n      System.out.println(\"Saturday\");\nbreak;\n    default:\n      System.out.println(\"Invalid\");\nbreak;\n    }\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Friday<\/div>\n<h4>6. Jump statements in Java<\/h4>\n<p>The jump statement unconditionally transfers the flow of the program within a function.<\/p>\n<p>Java provides three types of jump statements which are:<\/p>\n<ul>\n<li>return<\/li>\n<li>break<\/li>\n<li>continue<\/li>\n<\/ul>\n<p>Out of these three, you can use the return statement anywhere in the program whereas break and continue are used inside the smallest block of code like loops, etc.<\/p>\n<h5><strong>6.1. The break Statement:<\/strong><\/h5>\n<p>The break statement enables a program to skip over a part of the code. A <strong>break<\/strong> statement is generally used to terminate the loops like <strong>while, do-while, for<\/strong> and a <strong>switch<\/strong> statement. The execution resumes at the statement immediately after the terminated statement.<\/p>\n<p><strong>Syntax of break statement in loops:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">while(expression1)\n{\n  statement1;\n  if(expression2)\n    break; \/\/From here the control goes to statement3\n    :\n  statement2;\n}\nstatement3;\n\nfor(int ; expression1 ; update)\n{\n  statement1;\n  if(expression2)\n    break; \/\/From here the control goes to statement3\n    :\n  statement2;\n}\nstatement3;\n\ndo\n{\n  statement1;\n  if(expression2)\n  break; \/\/From here the control goes to statement3\n  :\n  statement2;\n} while(expression);\nstatement3;<\/pre>\n<p><em>The following figure shows the break statement of Java.<\/em><\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/break-statement-in-java.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-76661\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/break-statement-in-java.png\" alt=\"break-statement-in-java\" width=\"462\" height=\"512\" \/><\/a><\/p>\n<p><strong>Code to illustrate break statement:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.DecisionMakingDemo;\npublic class BreakStatementDemo\n{\n  \/\/Java program to illustrate using break to exit a loop\n  public static void main(String args[])\n  {\n    int iterator = 0;\n\n    \/\/ Initially loop is set to run from 0 to 9\n    while(iterator &lt; 10)\n    {\n      System.out.println(\"iterator: \" + iterator);\n      iterator++;\n      \/\/ loop will terminate when iterator is 5.\n      if (iterator == 5)\n        break;\n    }\n    System.out.println(\"Loop complete.\");\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">iterator: 0<br \/>\niterator: 1<br \/>\niterator: 2<br \/>\niterator: 3<br \/>\niterator: 4<br \/>\nLoop complete.<\/div>\n<h5><strong>6.2. The continue Statement:<\/strong><\/h5>\n<p>The <strong>continue<\/strong> is another jump statement similar to the break statement. It also skips over a part of the code, like the break statement.<\/p>\n<p>But the continue statement is different from the break statement in a way that instead of terminating from the loop, it goes to the next iteration of the loop, skipping any code in between.<\/p>\n<p>The continue statement skips the rest of the loop statements and causes the next iteration of the loop.<\/p>\n<p><strong>Syntax of continue statement in loops:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">while(expression1)\n{\n  statement1;\n  if(expression2)\n    continue;\n  \/\/From here the control goes to expression1 of while loop\n  :\n  statement2;\n}\nstatement3;\n\nfor(int ; expression1 ; update)\n{\n  statement1;\n  if(expression2)\n    continue;\n  \/\/From here the control goes to update expression in for loop\n    :\n  statement2;\n}\nstatement3;\n\ndo\n{\n  statement1;\n  if(expression2)\n    continue;\n  \/\/From here the control goes to expression1 of while loop\n    :\n  statement2;\n} while(expression);\nstatement3;<\/pre>\n<p><em>The following figure shows the continue statement of Java.<\/em><\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/Continue-Statement-in-Java.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-76662\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/Continue-Statement-in-Java.png\" alt=\"Continue-Statement-in-Java\" width=\"500\" height=\"500\" \/><\/a><\/p>\n<p><strong>Code to illustrate the use of continue statement:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.DecisionMakingDemo;\npublic class ContinueStatementDemo\n{\n  \/\/Java program to illustrate using the continue to exit a loop\n  public static void main(String args[])\n  {\n    int iterator = 0;\n\n    \/\/ Initially loop is set to run from 0 to 10\n    while(iterator &lt;= 10)\n    {\n      iterator++;\n      \/\/ If the number is odd, skip and continue\n      if (iterator %2 == 1)\n        continue;\n      \/\/ If the number is odd,print it\n      System.out.println(\"iterator: \" + iterator);\n    }\n    System.out.println(\"Loop complete.\");\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">iterator: 2<br \/>\niterator: 4<br \/>\niterator: 6<br \/>\niterator: 8<br \/>\niterator: 10<br \/>\nLoop complete.<\/div>\n<h5><strong>6.3. The return Statement:<\/strong><\/h5>\n<p>The return statement is used to return from a function or a method. This statement is useful in two ways. First, it is used to immediately exit from the function.<\/p>\n<p>The second use of return is that it returns a value to the calling code. The compiler will bypass or skip every statement after the encounter of a return statement.<\/p>\n<p><strong>Code to illustrate return statement:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.DecisionMakingDemo;\npublic class ReturnStatementDemo\n{\n  \/\/Java program to illustrate using return statement to exit a function\n  public static void main(String args[])\n  {\n    int iterator = 0;\n\n    \/\/ Initially loop is set to run from 0 to 10\n    while(iterator &lt;= 10)\n    {\n      iterator++;\n      \/\/ If the number is odd, print it\n      if (iterator %2 == 1)\n        System.out.println(\"iterator: \" + iterator);\n      return; \/\/the remaining code will be skipped\n    }\n    System.out.println(\"Loop complete.\");\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">iterator: 1<\/div>\n<h3>Summary<\/h3>\n<p>The decision-making statements are useful for easy coding in Java. These statements are necessary for deciding what to do in response to changing conditions. In this Java article, we covered each of the decision making statements along with their syntax and code examples.<\/p>\n<p>We also learned the concept of jump statements which will help you with efficient programming. This article will surely help you in building and strengthening your concepts on decision making in Java.<\/p>\n<p>Thank you for reading our article. Don&#8217;t forget to share your feedback through the comment section below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Each programming language provides some constructs which are necessary for decision making and also for the flow of control of a program. Decision making is really important when we get trapped in some dilemma.&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":76674,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[183],"tags":[1722,1723,1724,1725,1726,1727,1728,1729,1730,1731,1732,1733],"class_list":["post-76494","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-break-statement-in-java","tag-continue-statement-in-java","tag-decision-making-in-java","tag-if-else-if-statement-in-java","tag-if-statement-in-java","tag-if-else-statement-in-java","tag-java-decision-making","tag-java-decision-making-statement","tag-jump-statement-in-java","tag-nested-if-statement-in-java","tag-return-statement-in-java","tag-switch-statement-in-java"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Decision Making in Java - Explore the types of Statements with Syntax - TechVidvan<\/title>\n<meta name=\"description\" content=\"Understand the concept of Decision Making in Java &amp; explore the different types of Decision Making Statements in Java, explained with their sub categories and syntax.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/decision-making-in-java\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Decision Making in Java - Explore the types of Statements with Syntax - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Understand the concept of Decision Making in Java &amp; explore the different types of Decision Making Statements in Java, explained with their sub categories and syntax.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/decision-making-in-java\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-02-17T10:48:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/02\/types-of-decision-making-in-java-2.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"802\" \/>\n\t<meta property=\"og:image:height\" content=\"420\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Decision Making in Java - Explore the types of Statements with Syntax - TechVidvan","description":"Understand the concept of Decision Making in Java & explore the different types of Decision Making Statements in Java, explained with their sub categories and syntax.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/techvidvan.com\/tutorials\/decision-making-in-java\/","og_locale":"en_US","og_type":"article","og_title":"Decision Making in Java - Explore the types of Statements with Syntax - TechVidvan","og_description":"Understand the concept of Decision Making in Java & explore the different types of Decision Making Statements in Java, explained with their sub categories and syntax.","og_url":"https:\/\/techvidvan.com\/tutorials\/decision-making-in-java\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2020-02-17T10:48:59+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/02\/types-of-decision-making-in-java-2.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/decision-making-in-java\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/decision-making-in-java\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Decision Making in Java &#8211; Explore the types of Statements with Syntax","datePublished":"2020-02-17T10:48:59+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/decision-making-in-java\/"},"wordCount":1376,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/decision-making-in-java\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/02\/types-of-decision-making-in-java-2.jpg","keywords":["break statement in java","Continue Statement in Java","Decision Making in Java","if else if statement in Java","if statement in java","if-else statement in Java","Java Decision Making","Java Decision Making Statement","Jump Statement in Java","nested if statement in Java","Return Statement in Java","Switch Statement in Java"],"articleSection":["Java Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/decision-making-in-java\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/decision-making-in-java\/","url":"https:\/\/techvidvan.com\/tutorials\/decision-making-in-java\/","name":"Decision Making in Java - Explore the types of Statements with Syntax - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/decision-making-in-java\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/decision-making-in-java\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/02\/types-of-decision-making-in-java-2.jpg","datePublished":"2020-02-17T10:48:59+00:00","description":"Understand the concept of Decision Making in Java & explore the different types of Decision Making Statements in Java, explained with their sub categories and syntax.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/decision-making-in-java\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/decision-making-in-java\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/decision-making-in-java\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/02\/types-of-decision-making-in-java-2.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/02\/types-of-decision-making-in-java-2.jpg","width":802,"height":420,"caption":"decision making types"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/decision-making-in-java\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Decision Making in Java &#8211; Explore the types of Statements with Syntax"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/76494","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=76494"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/76494\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/76674"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=76494"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=76494"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=76494"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}