{"id":5174,"date":"2021-03-23T11:40:57","date_gmt":"2021-03-23T11:40:57","guid":{"rendered":"https:\/\/ded9.com\/?p=5174"},"modified":"2025-10-28T08:14:00","modified_gmt":"2025-10-28T08:14:00","slug":"learn-phrases-commands-and-blocks-in-java-plain-language","status":"publish","type":"post","link":"https:\/\/ded9.com\/tr\/learn-phrases-commands-and-blocks-in-java-plain-language\/","title":{"rendered":"Discover Java Phrases, Commands &#038; Blocks Explained Plainly"},"content":{"rendered":"<p><span style=\"font-size: 12pt;\">This tutorial teaches you about <a href=\"https:\/\/www.programiz.com\/java-programming\/expressions-statements-blocks\" target=\"_blank\" rel=\"noopener\">expressions, statements, blocks<\/a>, and the difference between a phrase and a Command. We used phrases, <a href=\"https:\/\/ded9.com\/basic-command-codes-and-linux-commands-in-cpanel\/\">commands<\/a>, and blocks in previous tutorials without discussing them in detail.<\/span><\/p>\n<p>Now that you know what variables, operators, and literals are, it will be easier to understand these concepts.<span id=\"more-50060\"><\/span><\/p>\n<h2><span style=\"font-size: 18pt;\">Java Expressions<\/span><\/h2>\n<p>Expressions include variables, operators, literals, and method calls that evaluate a single value.<\/p>\n<p>Let&#8217;s give an example:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-java&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">int score;\r\n\r\nscore = 90;\r\n\r\nHere, score = 90 is the expression that returns int.\r\n\r\nDouble a = 2.2, b = 3.4, result;\r\n\r\nresult = a + b - 3.4;\r\n\r\nHere, a + b is 3.4.\r\n\r\nif (number1 == number2)\r\n\r\nSystem.out.println (\u201cNumber 1 is larger than number 2\u201d);<\/pre>\n<\/div>\n<p>Here, number2 == number1 is the expression that Boolean returns. Similarly, &#8220;Number 1 is larger than number 2&#8221; is a String expression.<\/p>\n<h2>Java Statements<\/h2>\n<p>Commands form a complete execution unit. For example,<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-java&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">int score = 9 * 5;<\/pre>\n<\/div>\n<p>Here, 9 * 5 is a statement that returns 45, and int score = 9 * 5 is a Command.<\/p>\n<p>Phrases are part of commands.<\/p>\n<p><strong>Grammatical expressions<\/strong><\/p>\n<p>Some expressions can be used with;\u00a0Terminated are known as commands. For example:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-java&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">number = 10;<\/pre>\n<\/div>\n<p>Here, number = 10 is a phrase, and number = 10 is a command that the compiler can execute.<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-java&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">++ number;<\/pre>\n<\/div>\n<p>Here, ++ number is the expression, while ++ number; Is a Command.<\/p>\n<p>Definitive commands<\/p>\n<p>Defines commands that define variables. For example,<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-java&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">Double tax = 9.5;<\/pre>\n<\/div>\n<p>The above Command defines the tax variable with an initial value of 9.5.<\/p>\n<p>Control flow commands are also used in decision-making and loops in Java. You will learn control flow commands in later tutorials.<\/p>\n<h2><span style=\"font-size: 18pt;\">Java block<\/span><\/h2>\n<p>A block is a group of expressions (zero or more) enclosed in parentheses. For example,<\/p>\n<blockquote>\n<ol>\n<li dir=\"ltr\">class AssignmentOperator {<\/li>\n<li dir=\"ltr\">public static void main (String [] args) {<\/li>\n<li dir=\"ltr\"><\/li>\n<li dir=\"ltr\">String band = &#8220;Beatles&#8221;;<\/li>\n<li dir=\"ltr\"><\/li>\n<li dir=\"ltr\">if (band == \u201cBeatles\u201d) {\/\/ start of block<\/li>\n<li dir=\"ltr\">System.out.print (&#8220;Hey&#8221;);<\/li>\n<li dir=\"ltr\">System.out.print (\u201cJude!\u201d);<\/li>\n<li dir=\"ltr\">} \/\/ end of block<\/li>\n<li dir=\"ltr\">}<\/li>\n<li dir=\"ltr\">}<\/li>\n<\/ol>\n<\/blockquote>\n<p>Above are two phrases<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-java&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">System.out.print (\"Hey\");<\/pre>\n<\/div>\n<p>And<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-java&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">System.out.print (\u201cJude!\u201d);<\/pre>\n<\/div>\n<p>Inside the listed block.<\/p>\n<p>A block may have no expression. Consider the following examples:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-java&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">class AssignmentOperator {\r\n\r\npublic static void main (String [] args) {\r\n\r\nif (10&gt; 5) {\/\/ start of block\r\n\r\n} \/\/ end of block\r\n\r\n}\r\n\r\n}\r\n\r\nclass AssignmentOperator {\r\n\r\npublic static void main (String [] args) {\/\/ start of block\r\n\r\n} \/\/ end of block\r\n\r\n}<\/pre>\n<h2>FAQ<\/h2>\n<div id=\"rank-math-rich-snippet-wrapper\"><div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-1\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">What is an expression in Java?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>An expression is any combination of variables, operations, and method calls that produces a value.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-2\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">What is a statement in Java?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>A statement is a complete command in code that performs an action (like a method call, assignment, or declaration).<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-3\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">What is a block in Java?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>A block is a group of one or more statements enclosed in { }, used to organise code into logical sections.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial teaches you about expressions, statements, blocks, and the difference between a phrase and a Command. We used phrases, commands, and blocks in previous tutorials without discussing them in detail. Now that you know what variables, operators, and literals are, it will be easier to understand these concepts. Java Expressions Expressions include variables, operators, [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":5175,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1077],"tags":[840],"class_list":["post-5174","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-java"],"acf":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/posts\/5174","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/comments?post=5174"}],"version-history":[{"count":4,"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/posts\/5174\/revisions"}],"predecessor-version":[{"id":264087,"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/posts\/5174\/revisions\/264087"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/media\/5175"}],"wp:attachment":[{"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/media?parent=5174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/categories?post=5174"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/tags?post=5174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}