{"id":73061,"date":"2022-07-25T03:10:33","date_gmt":"2022-07-25T03:10:33","guid":{"rendered":"https:\/\/itsourcecode.com\/?p=73061"},"modified":"2022-07-25T03:10:39","modified_gmt":"2022-07-25T03:10:39","slug":"20-useful-java-syntax-cheat-sheet-developer-should-know","status":"publish","type":"post","link":"https:\/\/itsourcecode.com\/java-tutorial\/20-useful-java-syntax-cheat-sheet-developer-should-know\/","title":{"rendered":"20 Useful Java Syntax Cheat Sheet Developer Should Know"},"content":{"rendered":"\n<p>This article will give you the list of useful Java syntax cheat sheet every developer should know before doing the actual java programming.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-what-is-java\"><strong><strong>What is Java?<\/strong><\/strong><\/h2>\n\n\n\n<p>Java is the high-level, object-oriented, robust, secure programming language, platform-independent, high-performance, Multi-threaded, and portable programming language. It was developed by&nbsp;<strong>James Gosling<\/strong>&nbsp;in June 1991. It can also be known as the platform as it provides its own JRE and API.<\/p>\n\n\n\n<div class=\"wp-block-yoast-seo-table-of-contents yoast-table-of-contents\"><h2>Table of contents<\/h2><ul><li><a href=\"#h-what-is-java\" data-level=\"2\">What is Java?<\/a><\/li><li><a href=\"#h-java-programming-popularity\" data-level=\"2\">Java programming popularity<\/a><\/li><li><a href=\"#h-single-line-comments\" data-level=\"2\">Single-line Comments<\/a><\/li><li><a href=\"#h-java-operators\" data-level=\"2\">Java\u00a0Operators<\/a><ul><li><a href=\"#h-arithmetic-operators\" data-level=\"3\">Arithmetic operators<\/a><\/li><li><a href=\"#h-assignment-operators\" data-level=\"3\">Assignment operators<\/a><\/li><li><a href=\"#h-comparison-operators\" data-level=\"3\">Comparison operators<\/a><\/li><li><a href=\"#h-logical-operators\" data-level=\"3\">Logical operators<\/a><\/li><\/ul><\/li><li><a href=\"#h-java-conditions-and-if-statements\" data-level=\"2\">Java Conditions and If Statements<\/a><ul><li><a href=\"#h-the-else-if-statement\" data-level=\"3\">The else if Statement<\/a><\/li><li><a href=\"#h-short-hand-if-else-ternary-operator\" data-level=\"3\">Short Hand If&#8230;Else (Ternary Operator)<\/a><\/li><\/ul><\/li><li><a href=\"#h-java-switch-statements\" data-level=\"2\">Java Switch Statements<\/a><\/li><\/ul><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-java-programming-popularity\"><strong>Java programming popularity<\/strong><\/h2>\n\n\n\n<p>Jonathan Sandals&nbsp;in his post about&nbsp;<strong><a href=\"https:\/\/www.codingdojo.com\/blog\/top-7-programming-languages\">Top 7 Programming Languages Of 2020<\/a><\/strong>&nbsp;last February 7, 2020, listed that Java is being in the Top 2 Most programming language in the year 2020. The philosophy \u201cWrite once, work&nbsp;anywhere,\u201d&nbsp;it\u2019s&nbsp;very popular with businesses looking to make sure their applications have a consistent user experience. Java programs should be able to run over a network, without it mattering what operating system the user is running. based on the article published by Northeastern University Graduate programs about THE 10 MOST POPULAR PROGRAMMING LANGUAGES TO LEARN IN 2021&nbsp;said that there are&nbsp;29,000&nbsp;jobs&nbsp;with&nbsp;an annual<em> average salary<\/em>&nbsp;of&nbsp;<strong>$104,000<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Java Systax<\/strong><\/h2>\n\n\n\n<p>Here is the following Java syntax that may help you during your programming journey.<\/p>\n\n\n\n<p>The Java code below called&nbsp;<code><em><strong>Main.java<\/strong><\/em><\/code>, and this code will print <strong>&#8220;Hello World&#8221;<\/strong> to the screen:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class Main {\n  public static void main(String&#91;] args) {\n    System.out.println(\"Hello World\");\n  }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-single-line-comments\"><strong>Single-line Comments<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ This is a comment\nSystem.out.println(\"Hello World\");<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Java Multi-line Comments<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\/* The code below will print the words Hello World\nto the screen, and it is amazing *\/\nSystem.out.println(\"Hello World\");<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Jav<strong>a&nbsp;Variables<\/strong><\/h2>\n\n\n\n<p>Variables are used to store values in computer memory. See the list below of the commonly used java variables<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong><code>String<\/code>&nbsp;<\/strong>&#8211; store values such text, like as &#8220;Hello&#8221;. String values are surrounded by double quotes<\/li><li><strong><code>int<\/code>&nbsp;<\/strong>&#8211; stores integers values such (whole numbers), without decimals, like as 123 or -123<\/li><li><strong><code>float<\/code>&nbsp;<\/strong>&#8211; stores values such floating point numbers, with decimals, like as 19.99 or -19.99<\/li><li><strong><code>char<\/code>&nbsp;<\/strong>&#8211; stores values such single characters, such as &#8216;a&#8217; or &#8216;B&#8217;. Char values are surrounded by single quotes<\/li><li><strong><code>boolean<\/code>&nbsp;<\/strong>&#8211; stores values with two states: Yes or No, On or Off, true or false<\/li><\/ul>\n\n\n\n<p>See the code below to declare java variables.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>type variableName = value;<\/code><\/pre>\n\n\n\n<p>See the code below on how to assign value to java variables using different data types.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int myNum = 5;\nfloat myFloatNum = 5.99f;\nchar myLetter = 'D';\nboolean myBool = true;\nString myText = \"Hello\";<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-java-operators\"><strong>Java&nbsp;Operators<\/strong><\/h2>\n\n\n\n<p>In Java, operators are divided into the following groups.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Arithmetic operators<\/li><li>Assignment operators<\/li><li>Comparison operators<\/li><li>Logical operators<\/li><li>Bitwise operators<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-arithmetic-operators\">Arithmetic operators<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Operator<\/td><td>Name<\/td><td>Description<\/td><td>Example<\/td><\/tr><tr><td>+<\/td><td>Addition<\/td><td>Adds together two values<\/td><td>x + y<\/td><\/tr><tr><td>&#8211;<\/td><td>Subtraction<\/td><td>Subtracts one value from another<\/td><td>x &#8211; y<\/td><\/tr><tr><td>*<\/td><td>Multiplication<\/td><td>Multiplies two values<\/td><td>x * y<\/td><\/tr><tr><td>\/<\/td><td>Division<\/td><td>Divides one value by another<\/td><td>x \/ y<\/td><\/tr><tr><td>%<\/td><td>Modulus<\/td><td>Returns the division remainder<\/td><td>x % y<\/td><\/tr><tr><td>++<\/td><td>Increment<\/td><td>Increases the value of a variable by 1<\/td><td>++x<\/td><\/tr><tr><td>&#8212;<\/td><td>Decrement<\/td><td>Decreases the value of a variable by 1<\/td><td>&#8211;x<\/td><\/tr><\/tbody><\/table><figcaption>Arithmetic operators<\/figcaption><\/figure>\n\n\n\n<p><strong>Sample Syntax using Arithmetic Operators<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int sum1 = 150 + 10;        \/\/ 160 (100 + 50)\nint sum2 = sum1 + 300;      \/\/ 460 (150 + 250)\nint sum3 = sum2 + sum2;     \/\/ 920 (460 + 460)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-assignment-operators\"><strong>Assignment operators<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Operator<\/td><td>Example<\/td><td>Same As<\/td><\/tr><tr><td>=<\/td><td>x = 5<\/td><td>x = 5<\/td><\/tr><tr><td>+=<\/td><td>x += 3<\/td><td>x = x + 3<\/td><\/tr><tr><td>-=<\/td><td>x -= 3<\/td><td>x = x &#8211; 3<\/td><\/tr><tr><td>*=<\/td><td>x *= 3<\/td><td>x = x * 3<\/td><\/tr><tr><td>\/=<\/td><td>x \/= 3<\/td><td>x = x \/ 3<\/td><\/tr><tr><td>%=<\/td><td>x %= 3<\/td><td>x = x % 3<\/td><\/tr><tr><td>&amp;=<\/td><td>x &amp;= 3<\/td><td>x = x &amp; 3<\/td><\/tr><tr><td>|=<\/td><td>x |= 3<\/td><td>x = x | 3<\/td><\/tr><tr><td>^=<\/td><td>x ^= 3<\/td><td>x = x ^ 3<\/td><\/tr><tr><td>&gt;&gt;=<\/td><td>x &gt;&gt;= 3<\/td><td>x = x &gt;&gt; 3<\/td><\/tr><tr><td>&lt;&lt;=<\/td><td>x &lt;&lt;= 3<\/td><td>x = x &lt;&lt; 3<\/td><\/tr><\/tbody><\/table><figcaption> Assignment operators<\/figcaption><\/figure>\n\n\n\n<p>The code below shows how to assign a value to a variable.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int x = 10;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-comparison-operators\"><strong>Comparison operators<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Operator<\/td><td>Name<\/td><td>Example<\/td><\/tr><tr><td>==<\/td><td>Equal to<\/td><td>x == y<\/td><\/tr><tr><td>!=<\/td><td>Not equal<\/td><td>x != y<\/td><\/tr><tr><td>&gt;<\/td><td>Greater than<\/td><td>x &gt; y<\/td><\/tr><tr><td>&lt;<\/td><td>Less than<\/td><td>x &lt; y<\/td><\/tr><tr><td>&gt;=<\/td><td>Greater than or equal to<\/td><td>x &gt;= y<\/td><\/tr><tr><td>&lt;=<\/td><td>Less than or equal to<\/td><td>x &lt;= y<\/td><\/tr><\/tbody><\/table><figcaption> Comparison operators <\/figcaption><\/figure>\n\n\n\n<p>See the example code below showing the Comparison operators in java.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/Java-comparison-Operators.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1013\" height=\"414\" src=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/Java-comparison-Operators.png\" alt=\"\" class=\"wp-image-47062\" srcset=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/Java-comparison-Operators.png 1013w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/Java-comparison-Operators-300x123.png 300w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/Java-comparison-Operators-768x314.png 768w\" sizes=\"auto, (max-width: 1013px) 100vw, 1013px\" \/><\/a><figcaption>Code for Java Comparison Operators<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-logical-operators\"><strong>Logical operators<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Operator<\/td><td>Name<\/td><td>Description<\/td><td>Example<\/td><\/tr><tr><td>&amp;&amp;&nbsp;<\/td><td>Logical and<\/td><td>Returns true if both statements are true<\/td><td>x &lt; 5 &amp;&amp;&nbsp; x &lt; 10<\/td><\/tr><tr><td>||&nbsp;<\/td><td>Logical or<\/td><td>Returns true if one of the statements is true<\/td><td>x &lt; 5 || x &lt; 4<\/td><\/tr><tr><td>!<\/td><td>Logical not<\/td><td>Reverse the result, returns false if the result is true<\/td><td>!(x &lt; 5 &amp;&amp; x &lt; 10)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>See the sample program below that shows logical operators in Java.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/Java-Logical-Operators.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1009\" height=\"371\" src=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/Java-Logical-Operators.png\" alt=\"\" class=\"wp-image-47064\" srcset=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/Java-Logical-Operators.png 1009w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/Java-Logical-Operators-300x110.png 300w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/Java-Logical-Operators-768x282.png 768w\" sizes=\"auto, (max-width: 1009px) 100vw, 1009px\" \/><\/a><figcaption> Syntax of using<strong> Logical Operators in java <\/strong>  <\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-java-conditions-and-if-statements\"><strong>Java Conditions and If Statements<\/strong><\/h2>\n\n\n\n<p>In Java, the <em>if statement<\/em> is used to evaluate the condition. It usually check the boolean condition, either true or false.<\/p>\n\n\n\n<p>Here are the various types of if statement in Java.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>The if Statement<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-if-statement.png\"><img loading=\"lazy\" decoding=\"async\" width=\"992\" height=\"95\" src=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-if-statement.png\" alt=\"\" class=\"wp-image-47067\" srcset=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-if-statement.png 992w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-if-statement-300x29.png 300w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-if-statement-768x74.png 768w\" sizes=\"auto, (max-width: 992px) 100vw, 992px\" \/><\/a><figcaption> Syntax of using<strong> If Statement in java <\/strong>  <\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>The else Statement<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-else-Statement.png\"><img loading=\"lazy\" decoding=\"async\" width=\"993\" height=\"155\" src=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-else-Statement.png\" alt=\"\" class=\"wp-image-47068\" srcset=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-else-Statement.png 993w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-else-Statement-300x47.png 300w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-else-Statement-768x120.png 768w\" sizes=\"auto, (max-width: 993px) 100vw, 993px\" \/><\/a><figcaption>  Syntax of using<strong> Else Statement in java <\/strong> <\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-the-else-if-statement\"><strong>The else if Statement<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/Java-else-if-statement.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"197\" src=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/Java-else-if-statement-1024x197.png\" alt=\"\" class=\"wp-image-47069\" srcset=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/Java-else-if-statement-1024x197.png 1024w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/Java-else-if-statement-300x58.png 300w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/Java-else-if-statement-768x147.png 768w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/Java-else-if-statement.png 1052w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption> Syntax of using<strong> Else-if statement in java <\/strong><\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-short-hand-if-else-ternary-operator\"><strong>Short Hand If&#8230;Else (Ternary Operator)<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">variable = (condition) ? expressionTrue :  expressionFalse;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-java-switch-statements\"><strong>Java Switch Statements<\/strong><\/h2>\n\n\n\n<p>The&nbsp;<a href=\"https:\/\/www.programiz.com\/java-programming\/switch-statement\" class=\"ek-link\"><code>switch<\/code>&nbsp;statement<\/a> allows us to execute a block of code among many alternatives.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-switch-statements.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1009\" height=\"273\" src=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-switch-statements.png\" alt=\"\" class=\"wp-image-47071\" srcset=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-switch-statements.png 1009w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-switch-statements-300x81.png 300w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-switch-statements-768x208.png 768w\" sizes=\"auto, (max-width: 1009px) 100vw, 1009px\" \/><\/a><figcaption> Syntax of using Switch Statements in java <\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Java Loops<\/strong><\/h2>\n\n\n\n<p>The <strong>Loops<\/strong> in Java is used to execute a block of code as long as a specified condition is reached. See the different types of loops in Java below.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Java&nbsp;While Loop<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image size-full caption-align-left\"><a href=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-while-loop.png\"><img loading=\"lazy\" decoding=\"async\" width=\"994\" height=\"103\" src=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-while-loop.png\" alt=\"\" class=\"wp-image-47073\" srcset=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-while-loop.png 994w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-while-loop-300x31.png 300w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-while-loop-768x80.png 768w\" sizes=\"auto, (max-width: 994px) 100vw, 994px\" \/><\/a><figcaption> Syntax of using <strong>While loop in java<\/strong> <\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>The Do\/While Loop<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-do-while-loop.png\"><img loading=\"lazy\" decoding=\"async\" width=\"994\" height=\"122\" src=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-do-while-loop.png\" alt=\"\" class=\"wp-image-47074\" srcset=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-do-while-loop.png 994w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-do-while-loop-300x37.png 300w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-do-while-loop-768x94.png 768w\" sizes=\"auto, (max-width: 994px) 100vw, 994px\" \/><\/a><figcaption> Syntax of using <strong>Do While loop in java<\/strong> <\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Java&nbsp;For Loop<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-for-loop.png\"><img loading=\"lazy\" decoding=\"async\" width=\"999\" height=\"108\" src=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-for-loop.png\" alt=\"\" class=\"wp-image-47075\" srcset=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-for-loop.png 999w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-for-loop-300x32.png 300w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-for-loop-768x83.png 768w\" sizes=\"auto, (max-width: 999px) 100vw, 999px\" \/><\/a><figcaption> Syntax of using <strong>For loop in java <\/strong><\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>For-Each Loop<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-for-each-loop.png\"><img loading=\"lazy\" decoding=\"async\" width=\"992\" height=\"87\" src=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-for-each-loop.png\" alt=\"\" class=\"wp-image-47076\" srcset=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-for-each-loop.png 992w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-for-each-loop-300x26.png 300w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/11\/java-for-each-loop-768x67.png 768w\" sizes=\"auto, (max-width: 992px) 100vw, 992px\" \/><\/a><figcaption>Syntax of using <strong>For each loop in java<\/strong><\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>This article will give you the list of useful Java syntax cheat sheet every developer should know before doing the actual java programming. What is Java? Java is the high-level, &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"20 Useful Java Syntax Cheat Sheet Developer Should Know\" class=\"read-more button\" href=\"https:\/\/itsourcecode.com\/java-tutorial\/20-useful-java-syntax-cheat-sheet-developer-should-know\/#more-73061\" aria-label=\"Read more about 20 Useful Java Syntax Cheat Sheet Developer Should Know\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":73137,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61033],"tags":[93788,93787],"class_list":["post-73061","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java-tutorial","tag-java-cheat-sheet","tag-java-syntax-cheat-sheet","resize-featured-image"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>20 Useful Java Syntax Cheat Sheet Developer Should Know<\/title>\n<meta name=\"description\" content=\"This article will give you the list of useful Java syntax cheat sheet every developer should know before doing the actual java programming.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/itsourcecode.com\/java-tutorial\/20-useful-java-syntax-cheat-sheet-developer-should-know\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"20 Useful Java Syntax Cheat Sheet Developer Should Know\" \/>\n<meta property=\"og:description\" content=\"This article will give you the list of useful Java syntax cheat sheet every developer should know before doing the actual java programming.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/itsourcecode.com\/java-tutorial\/20-useful-java-syntax-cheat-sheet-developer-should-know\/\" \/>\n<meta property=\"og:site_name\" content=\"Itsourcecode.com\" \/>\n<meta property=\"article:published_time\" content=\"2022-07-25T03:10:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-25T03:10:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/07\/Java-Syntax-Cheat-Sheet.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1460\" \/>\n\t<meta property=\"og:image:height\" content=\"900\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"itsourcecode\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"itsourcecode\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/java-tutorial\\\/20-useful-java-syntax-cheat-sheet-developer-should-know\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/java-tutorial\\\/20-useful-java-syntax-cheat-sheet-developer-should-know\\\/\"},\"author\":{\"name\":\"itsourcecode\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#\\\/schema\\\/person\\\/ad9e0497e03b85a9ca299d935298f5dc\"},\"headline\":\"20 Useful Java Syntax Cheat Sheet Developer Should Know\",\"datePublished\":\"2022-07-25T03:10:33+00:00\",\"dateModified\":\"2022-07-25T03:10:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/java-tutorial\\\/20-useful-java-syntax-cheat-sheet-developer-should-know\\\/\"},\"wordCount\":865,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#\\\/schema\\\/person\\\/ad9e0497e03b85a9ca299d935298f5dc\"},\"image\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/java-tutorial\\\/20-useful-java-syntax-cheat-sheet-developer-should-know\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/Java-Syntax-Cheat-Sheet.png\",\"keywords\":[\"java cheat sheet\",\"java syntax cheat sheet\"],\"articleSection\":[\"Java Tutorial\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/itsourcecode.com\\\/java-tutorial\\\/20-useful-java-syntax-cheat-sheet-developer-should-know\\\/#respond\"]}],\"accessibilityFeature\":[\"tableOfContents\"]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/java-tutorial\\\/20-useful-java-syntax-cheat-sheet-developer-should-know\\\/\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/java-tutorial\\\/20-useful-java-syntax-cheat-sheet-developer-should-know\\\/\",\"name\":\"20 Useful Java Syntax Cheat Sheet Developer Should Know\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/java-tutorial\\\/20-useful-java-syntax-cheat-sheet-developer-should-know\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/java-tutorial\\\/20-useful-java-syntax-cheat-sheet-developer-should-know\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/Java-Syntax-Cheat-Sheet.png\",\"datePublished\":\"2022-07-25T03:10:33+00:00\",\"dateModified\":\"2022-07-25T03:10:39+00:00\",\"description\":\"This article will give you the list of useful Java syntax cheat sheet every developer should know before doing the actual java programming.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/java-tutorial\\\/20-useful-java-syntax-cheat-sheet-developer-should-know\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/itsourcecode.com\\\/java-tutorial\\\/20-useful-java-syntax-cheat-sheet-developer-should-know\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/java-tutorial\\\/20-useful-java-syntax-cheat-sheet-developer-should-know\\\/#primaryimage\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/Java-Syntax-Cheat-Sheet.png\",\"contentUrl\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/Java-Syntax-Cheat-Sheet.png\",\"width\":1460,\"height\":900,\"caption\":\"Java Syntax Cheat Sheet\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/java-tutorial\\\/20-useful-java-syntax-cheat-sheet-developer-should-know\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/itsourcecode.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"20 Useful Java Syntax Cheat Sheet Developer Should Know\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#website\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/\",\"name\":\"Itsourcecode.com\",\"description\":\"Partner In Your Coding Journey!\",\"publisher\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#\\\/schema\\\/person\\\/ad9e0497e03b85a9ca299d935298f5dc\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/itsourcecode.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#\\\/schema\\\/person\\\/ad9e0497e03b85a9ca299d935298f5dc\",\"name\":\"itsourcecode\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/IT-SOURCECODE_ICON-07.jpg\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/IT-SOURCECODE_ICON-07.jpg\",\"contentUrl\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/IT-SOURCECODE_ICON-07.jpg\",\"width\":409,\"height\":409,\"caption\":\"itsourcecode\"},\"logo\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/IT-SOURCECODE_ICON-07.jpg\"},\"description\":\"Hello Itsourcecoders, welcome to itsourcecode.com. I'm Joken Villanueva, MIT a passionate Blogger, Programmer and a Hobbyist. I started Itsourcecode because I wanted to give back and Share all the learnings and knowledge I've learned in my career and I believe through this website I would be able to help and assist those newbie programmers in enhancing their skills from different programming languages. So let us all help each other by sharing our ideas!\",\"sameAs\":[\"https:\\\/\\\/itsourcecode.com\\\/\"],\"url\":\"https:\\\/\\\/itsourcecode.com\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"20 Useful Java Syntax Cheat Sheet Developer Should Know","description":"This article will give you the list of useful Java syntax cheat sheet every developer should know before doing the actual java programming.","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:\/\/itsourcecode.com\/java-tutorial\/20-useful-java-syntax-cheat-sheet-developer-should-know\/","og_locale":"en_US","og_type":"article","og_title":"20 Useful Java Syntax Cheat Sheet Developer Should Know","og_description":"This article will give you the list of useful Java syntax cheat sheet every developer should know before doing the actual java programming.","og_url":"https:\/\/itsourcecode.com\/java-tutorial\/20-useful-java-syntax-cheat-sheet-developer-should-know\/","og_site_name":"Itsourcecode.com","article_published_time":"2022-07-25T03:10:33+00:00","article_modified_time":"2022-07-25T03:10:39+00:00","og_image":[{"width":1460,"height":900,"url":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/07\/Java-Syntax-Cheat-Sheet.png","type":"image\/png"}],"author":"itsourcecode","twitter_card":"summary_large_image","twitter_misc":{"Written by":"itsourcecode","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/itsourcecode.com\/java-tutorial\/20-useful-java-syntax-cheat-sheet-developer-should-know\/#article","isPartOf":{"@id":"https:\/\/itsourcecode.com\/java-tutorial\/20-useful-java-syntax-cheat-sheet-developer-should-know\/"},"author":{"name":"itsourcecode","@id":"https:\/\/itsourcecode.com\/#\/schema\/person\/ad9e0497e03b85a9ca299d935298f5dc"},"headline":"20 Useful Java Syntax Cheat Sheet Developer Should Know","datePublished":"2022-07-25T03:10:33+00:00","dateModified":"2022-07-25T03:10:39+00:00","mainEntityOfPage":{"@id":"https:\/\/itsourcecode.com\/java-tutorial\/20-useful-java-syntax-cheat-sheet-developer-should-know\/"},"wordCount":865,"commentCount":0,"publisher":{"@id":"https:\/\/itsourcecode.com\/#\/schema\/person\/ad9e0497e03b85a9ca299d935298f5dc"},"image":{"@id":"https:\/\/itsourcecode.com\/java-tutorial\/20-useful-java-syntax-cheat-sheet-developer-should-know\/#primaryimage"},"thumbnailUrl":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/07\/Java-Syntax-Cheat-Sheet.png","keywords":["java cheat sheet","java syntax cheat sheet"],"articleSection":["Java Tutorial"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/itsourcecode.com\/java-tutorial\/20-useful-java-syntax-cheat-sheet-developer-should-know\/#respond"]}],"accessibilityFeature":["tableOfContents"]},{"@type":"WebPage","@id":"https:\/\/itsourcecode.com\/java-tutorial\/20-useful-java-syntax-cheat-sheet-developer-should-know\/","url":"https:\/\/itsourcecode.com\/java-tutorial\/20-useful-java-syntax-cheat-sheet-developer-should-know\/","name":"20 Useful Java Syntax Cheat Sheet Developer Should Know","isPartOf":{"@id":"https:\/\/itsourcecode.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/itsourcecode.com\/java-tutorial\/20-useful-java-syntax-cheat-sheet-developer-should-know\/#primaryimage"},"image":{"@id":"https:\/\/itsourcecode.com\/java-tutorial\/20-useful-java-syntax-cheat-sheet-developer-should-know\/#primaryimage"},"thumbnailUrl":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/07\/Java-Syntax-Cheat-Sheet.png","datePublished":"2022-07-25T03:10:33+00:00","dateModified":"2022-07-25T03:10:39+00:00","description":"This article will give you the list of useful Java syntax cheat sheet every developer should know before doing the actual java programming.","breadcrumb":{"@id":"https:\/\/itsourcecode.com\/java-tutorial\/20-useful-java-syntax-cheat-sheet-developer-should-know\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/itsourcecode.com\/java-tutorial\/20-useful-java-syntax-cheat-sheet-developer-should-know\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/itsourcecode.com\/java-tutorial\/20-useful-java-syntax-cheat-sheet-developer-should-know\/#primaryimage","url":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/07\/Java-Syntax-Cheat-Sheet.png","contentUrl":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/07\/Java-Syntax-Cheat-Sheet.png","width":1460,"height":900,"caption":"Java Syntax Cheat Sheet"},{"@type":"BreadcrumbList","@id":"https:\/\/itsourcecode.com\/java-tutorial\/20-useful-java-syntax-cheat-sheet-developer-should-know\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/itsourcecode.com\/"},{"@type":"ListItem","position":2,"name":"20 Useful Java Syntax Cheat Sheet Developer Should Know"}]},{"@type":"WebSite","@id":"https:\/\/itsourcecode.com\/#website","url":"https:\/\/itsourcecode.com\/","name":"Itsourcecode.com","description":"Partner In Your Coding Journey!","publisher":{"@id":"https:\/\/itsourcecode.com\/#\/schema\/person\/ad9e0497e03b85a9ca299d935298f5dc"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/itsourcecode.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/itsourcecode.com\/#\/schema\/person\/ad9e0497e03b85a9ca299d935298f5dc","name":"itsourcecode","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/01\/IT-SOURCECODE_ICON-07.jpg","url":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/01\/IT-SOURCECODE_ICON-07.jpg","contentUrl":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/01\/IT-SOURCECODE_ICON-07.jpg","width":409,"height":409,"caption":"itsourcecode"},"logo":{"@id":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/01\/IT-SOURCECODE_ICON-07.jpg"},"description":"Hello Itsourcecoders, welcome to itsourcecode.com. I'm Joken Villanueva, MIT a passionate Blogger, Programmer and a Hobbyist. I started Itsourcecode because I wanted to give back and Share all the learnings and knowledge I've learned in my career and I believe through this website I would be able to help and assist those newbie programmers in enhancing their skills from different programming languages. So let us all help each other by sharing our ideas!","sameAs":["https:\/\/itsourcecode.com\/"],"url":"https:\/\/itsourcecode.com\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/posts\/73061","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/comments?post=73061"}],"version-history":[{"count":3,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/posts\/73061\/revisions"}],"predecessor-version":[{"id":128713,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/posts\/73061\/revisions\/128713"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/media\/73137"}],"wp:attachment":[{"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/media?parent=73061"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/categories?post=73061"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/tags?post=73061"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}