{"id":13529,"date":"2020-03-18T18:19:16","date_gmt":"2020-03-19T01:19:16","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=13529"},"modified":"2023-12-01T02:34:01","modified_gmt":"2023-12-01T10:34:01","slug":"while-loop-java","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/while-loop-java\/","title":{"rendered":"While Loop Java"},"content":{"rendered":"\n<p>In programming, there are often instances where you have a repetitive task you want to execute multiple times. Loops are used to automate these repetitive tasks and allow you to create more efficient code.<br><\/p>\n\n\n\n<p>The <code>while<\/code> and <code>do...while<\/code> loops in Java are used to execute a block of code as long as a specific condition is met. These loops are similar to conditional <code>if<\/code> statements, which are blocks of code that only execute if a specific condition evaluates to true. Unlike an <code>if<\/code> statement, however, <code>while<\/code> loops run until a condition is no longer true.<br><\/p>\n\n\n\n<p>This tutorial will discuss the basics of the <code>while<\/code> and <code>do...while<\/code> statements in Java, and will walk through a few examples to demonstrate these statements in a Java program.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Java While Loop<\/h2>\n\n\n\n<p>The <code>while<\/code> loop loops through a block of code as long as a specified condition evaluates to true. The syntax for the <code>while<\/code> loop is similar to that of a traditional <code>if<\/code> statement. Here\u2019s the syntax for a Java <code>while<\/code> loop:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>while (condition_is_met) {\n\t\/\/ Code to execute\n}<\/pre><\/div>\n\n\n\n<p>The <code>while<\/code> loop will test the expression inside the parenthesis. If the Boolean expression evaluates to true, the body of the loop will execute, then the expression is evaluated again. The program will continue this process until the expression evaluates to false, after which point the <code>while<\/code> loop is halted, and the rest of the program will run.<br><\/p>\n\n\n\n<p>Let\u2019s walk through an example to show how the <code>while<\/code> loop can be used in Java. Say we are a carpenter and we have decided to start selling a new table in our store. We only have the capacity to make five tables, after which point people who want a table will be put on a waitlist.<br><\/p>\n\n\n\n<p>We want to create a program that tells us how many more people can order a table before we have to put them on a waitlist. We could do so by using a <code>while<\/code> loop like this which will execute the body of the loop until the number of orders made is not less than the limit:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>int limit = 5;\nint orders_made = 0;\nwhile (orders_made &lt; limit) {\n\torders_made++;\n\tint capacity = limit - orders_made;\n\tString message = capacity + \"more tables can be ordered.\";\n\tSystem.out.println(message);\n}<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>4 more tables can be ordered.\n3 more tables can be ordered.\n2 more tables can be ordered.\n1 more tables can be ordered.\n0 more tables can be ordered.<\/pre><\/div>\n\n\n\n<p>Let\u2019s break down our code. On the first line, we declare a variable called <code>limit<\/code> that keeps track of the maximum number of tables we can make. Then, we declare a variable called <code>orders_made<\/code> that stores the number of orders made.<br><\/p>\n\n\n\n<p>Our program then executes a <code>while<\/code> loop, which runs while <code>orders_made<\/code> is less than <code>limit<\/code>. Then, we use the <code>orders_made++<\/code> increment operator to add 1 to <code>orders_made<\/code>.<br><\/p>\n\n\n\n<p>After the increment operator has executed, our program calculates the remaining capacity of tables by subtracting \u201c<code>orders_made<\/code> from <code>limit<\/code>. Then, it prints out the message <code>[capacity] more tables can be ordered.<\/code> to the console.<br><\/p>\n\n\n\n<p>Our &#8220;while&#8221; statement stops running when <code>orders_made<\/code> is larger than <code>limit<\/code>.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Java Do While Loop<\/h2>\n\n\n\n<p>The <code>do\u2026while<\/code> loop is a type of <code>while<\/code> loop. The <code>do...while<\/code> loop executes the block of code in the <code>do<\/code> block once before checking if a condition evaluates to true. Then, the program will repeat the loop as long as the condition is true.<br><\/p>\n\n\n\n<p>The difference between <code>while<\/code> and <code>do...while<\/code> loops is that <code>while<\/code> loops evaluate a condition <strong>before<\/strong> running the code in the <code>while<\/code> block, whereas do&#8230;while loops evaluate the condition <strong>after<\/strong> running the code in the <code>do<\/code> block.<br><\/p>\n\n\n\n<p>The syntax for the do&#8230;while loop is as follows:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>do {\n\t\/\/ Code to execute\n} while (condition_is_met);<\/pre><\/div>\n\n\n\n<p>Let\u2019s use an example to explain how the do&#8230;while loop works.<br><\/p>\n\n\n\n<p>Say that we are creating a guessing game that asks a user to guess a number between one and ten. We want our user to first be asked to enter a number before checking whether they have guessed the right number. If the user enters the wrong number, they should be promoted to try again. We could accomplish this task using a do&#8230;while loop.<br><\/p>\n\n\n\n<p>Here\u2019s an example of a program that asks a user to guess a number, then evaluates whether the user has guessed the correct number using a do&#8230;while loop:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.Scanner;\nclass GuessingGame {\n\tpublic static void main(String[] args) {\nint number = 8;\nint guess = 0;\nScanner input = new Scanner(System.in);\ndo {\nSystem.out.print(\"Enter a number between 1 and 10: \");\nguess = input.nextInt();\n} while (number != guess);\nSystem.out.println(\"You're correct!\");\n\t}\n}<\/pre><\/div>\n\n\n\n<p>When we run our code, we are asked to guess the number <strong>first<\/strong>, before the condition in our <code>do...while<\/code> loop is evaluated. Here\u2019s what happens when we try to guess a few numbers before finally guessing the correct one:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Enter a number between 1 and 10: 9\nEnter a number between 1 and 10: 1\nEnter a number between 1 and 10: 4\nEnter a number between 1 and 10: 5\nEnter a number between 1 and 10: 8\nYou're correct!<\/pre><\/div>\n\n\n\n<p>Let\u2019s break down our code. First, we import the <code>util.Scanner<\/code> method, which is used to collect user input. Then we define a class called <code>GuessingGame<\/code> in which our code exists.<br><\/p>\n\n\n\n<p>We then define two variables: one called <code>number<\/code> which stores the number to be guessed, and another called <code>guess<\/code> which stores the users\u2019 guess.<br><\/p>\n\n\n\n<p>Then, we use the Scanner method to initiate our user input. We print out the message <code>Enter a number between 1 and 10:<\/code> to the console, then use the <code>input.nextInt()<\/code> method to retrieve the number the user has entered.<br><\/p>\n\n\n\n<p>After this code has executed, the do&#8230;while loop evaluates whether the number the user has guessed is equal to the number the user is to guess. If the user has guessed the wrong number, the contents of the <code>do<\/code> loop run again; if the user has guessed the right number, the do&#8230;while loop stops executing and the message <code>You\u2019re correct!<\/code> is printed to the console.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Infinite Loops<\/h2>\n\n\n\n<p>Infinite loops are loops that will keep running forever. If you have a <code>while<\/code> loop whose statement never evaluates to false, the loop will keep going and could crash your program. So, it\u2019s important to make sure that, at some point, your while loop stops running.<br><\/p>\n\n\n\n<p>Here\u2019s an example of an infinite loop in Java:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>while (true) {\n\t\/\/ Code to execute\n}<\/pre><\/div>\n\n\n\n<p>This loop will run infinitely. However, we can stop our program by using the <code>break<\/code> statement. Let\u2019s say we are creating a program that keeps track of how many tables are in-stock. We only have five tables in stock. When there are no tables in-stock, we want our <code>while<\/code> loop to stop. We could create a program that meets these specifications using the following code:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Boolean tables_in_stock = true;\nint orders_made = 0;\nwhile (tables_in_stock) {\n\torders_made++;\n\tif (orders_made == 5) {\n\t\tSystem.out.println(\"We are out of stock.\");\n\t\tbreak;\n\t} else {\n\t\tint tables_left = 5 - orders_made;\n\t\tString message = \"There are \" + tables_left + \" tables in stock.\";\n\t\tSystem.out.println(message);\n\t}\n}<\/pre><\/div>\n\n\n\n<p>When we run our code, the following response is returned:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>There are 4 tables in stock.\nThere are 3 tables in stock.\nThere are 2 tables in stock.\nThere are 1 tables in stock.\nWe are out of stock.<\/pre><\/div>\n\n\n\n<p>In our example, the <code>while<\/code> loop will continue to execute as long as <code>tables_in_stock<\/code> is true. But we never specify a way in which <code>tables_in_stock<\/code> can become false.<br><\/p>\n\n\n\n<p>So, in our code, we use a <code>break<\/code> statement that is executed when <code>orders_made<\/code> is equal to 5.<br><\/p>\n\n\n\n<p>This means that when fewer than five orders have been made, a message will be printed saying, <code>There are [tables_left] tables in stock.<\/code> But when <code>orders_made<\/code> is equal to 5, a message stating <code>We are out of stock.<\/code> will be printed to the console, and the break statement is executed. When the break statement is run, our <code>while<\/code> statement will stop.<\/p>\n\n\n\n<iframe loading=\"lazy\" frameborder=\"0\" width=\"100%\" height=\"400px\" src=\"https:\/\/repl.it\/@careerkarma\/Java-While-Loop?lite=true\"><\/iframe>\n<br>\n<br>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The <code>while<\/code> loop is used in Java executes a specific block of code while a statement is true, and stops when the statement is false. The <code>do...while<\/code> loop executes a block of code first, then evaluates a statement to see if the loop should keep going.<br><\/p>\n\n\n\n<p>This tutorial discussed how to use both the <code>while<\/code> and <code>do...while<\/code> loop in Java. We also talked about infinite loops and walked through an example of each of these methods in a Java program. You\u2019re now equipped with the knowledge you need to write Java <code>while<\/code> and <code>do...while<\/code> loops like an expert!<\/p>\n","protected":false},"excerpt":{"rendered":"In programming, there are often instances where you have a repetitive task you want to execute multiple times. Loops are used to automate these repetitive tasks and allow you to create more efficient code. The while and do...while loops in Java are used to execute a block of code as long as a specific condition&hellip;","protected":false},"author":240,"featured_media":13474,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17289],"tags":[],"class_list":{"0":"post-13529","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-java"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Java","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":"","is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>While Loop Java: A Complete Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"The \u201cwhile\u201d loop is used in Java to execute a block of code as long as a specific condition is met. Learn how to use these loops in this article.Slug: \/java-while-loop\/\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/while-loop-java\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"While Loop Java\" \/>\n<meta property=\"og:description\" content=\"The \u201cwhile\u201d loop is used in Java to execute a block of code as long as a specific condition is met. Learn how to use these loops in this article.Slug: \/java-while-loop\/\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/while-loop-java\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-03-19T01:19:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T10:34:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/adult-african-american-woman-blur-business-1181352.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"668\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/while-loop-java\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/while-loop-java\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"While Loop Java\",\"datePublished\":\"2020-03-19T01:19:16+00:00\",\"dateModified\":\"2023-12-01T10:34:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/while-loop-java\/\"},\"wordCount\":1121,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/while-loop-java\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/adult-african-american-woman-blur-business-1181352.jpg\",\"articleSection\":[\"Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/while-loop-java\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/while-loop-java\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/while-loop-java\/\",\"name\":\"While Loop Java: A Complete Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/while-loop-java\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/while-loop-java\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/adult-african-american-woman-blur-business-1181352.jpg\",\"datePublished\":\"2020-03-19T01:19:16+00:00\",\"dateModified\":\"2023-12-01T10:34:01+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"The \u201cwhile\u201d loop is used in Java to execute a block of code as long as a specific condition is met. Learn how to use these loops in this article.Slug: \/java-while-loop\/\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/while-loop-java\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/while-loop-java\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/while-loop-java\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/adult-african-american-woman-blur-business-1181352.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/adult-african-american-woman-blur-business-1181352.jpg\",\"width\":1000,\"height\":668},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/while-loop-java\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\/\/careerkarma.com\/blog\/java\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"While Loop Java\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"While Loop Java: A Complete Guide | Career Karma","description":"The \u201cwhile\u201d loop is used in Java to execute a block of code as long as a specific condition is met. Learn how to use these loops in this article.Slug: \/java-while-loop\/","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:\/\/careerkarma.com\/blog\/while-loop-java\/","og_locale":"en_US","og_type":"article","og_title":"While Loop Java","og_description":"The \u201cwhile\u201d loop is used in Java to execute a block of code as long as a specific condition is met. Learn how to use these loops in this article.Slug: \/java-while-loop\/","og_url":"https:\/\/careerkarma.com\/blog\/while-loop-java\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-03-19T01:19:16+00:00","article_modified_time":"2023-12-01T10:34:01+00:00","og_image":[{"width":1000,"height":668,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/adult-african-american-woman-blur-business-1181352.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/while-loop-java\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/while-loop-java\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"While Loop Java","datePublished":"2020-03-19T01:19:16+00:00","dateModified":"2023-12-01T10:34:01+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/while-loop-java\/"},"wordCount":1121,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/while-loop-java\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/adult-african-american-woman-blur-business-1181352.jpg","articleSection":["Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/while-loop-java\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/while-loop-java\/","url":"https:\/\/careerkarma.com\/blog\/while-loop-java\/","name":"While Loop Java: A Complete Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/while-loop-java\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/while-loop-java\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/adult-african-american-woman-blur-business-1181352.jpg","datePublished":"2020-03-19T01:19:16+00:00","dateModified":"2023-12-01T10:34:01+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"The \u201cwhile\u201d loop is used in Java to execute a block of code as long as a specific condition is met. Learn how to use these loops in this article.Slug: \/java-while-loop\/","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/while-loop-java\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/while-loop-java\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/while-loop-java\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/adult-african-american-woman-blur-business-1181352.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/adult-african-american-woman-blur-business-1181352.jpg","width":1000,"height":668},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/while-loop-java\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/careerkarma.com\/blog\/java\/"},{"@type":"ListItem","position":3,"name":"While Loop Java"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/13529","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=13529"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/13529\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/13474"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=13529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=13529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=13529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}