{"id":2264,"date":"2017-06-05T11:04:09","date_gmt":"2017-06-05T11:04:09","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=2264"},"modified":"2021-09-24T11:58:05","modified_gmt":"2021-09-24T11:58:05","slug":"java-program-to-find-the-minimum-element-in-an-array","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/java-program-to-find-the-minimum-element-in-an-array\/","title":{"rendered":"Java Program to find the minimum element in an array"},"content":{"rendered":"<h3>Problem Description<\/h3>\n<p>Write a Java Program to find the minimum element in an array. We will declare an array with some numbers. Loop each element in the array to find the minimum element in the given array.<\/p>\n<h3>Java Program<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\/\/********************************\r\n\/\/MinInArray.java\r\n\/\/********************************\r\n\r\npublic class MinInArray {\r\n  \/\/main method\r\n  public static void main(String[] args) {\r\n    int minValue= Integer.MAX_VALUE;\r\n    int[] arr = {2, 6, 18, 9, 56, 44, 63, 22, 76, 28}; \r\n\/\/ declare an array of numbers\t\r\n\r\n    for (int i = 0; i &lt; arr.length; i++) {\r\n      if(arr[i] &lt; minValue) {\r\n        minValue = arr[i];\r\n      }\r\n    }\r\n    System.out.print(\"The minimum element in the array is= \" + minValue);\r\n \/\/output min number\r\n  }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<h3>Program Output<\/h3>\n<p>The minimum element in the array is= 2<\/p>\n<h3>Screenshot<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2265\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Minimum-element-in-the-array.png\" alt=\"Minimum element\" width=\"1760\" height=\"1031\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Minimum-element-in-the-array.png 1760w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Minimum-element-in-the-array-300x176.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Minimum-element-in-the-array-1024x600.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Minimum-element-in-the-array-768x450.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Minimum-element-in-the-array-1536x900.png 1536w\" sizes=\"auto, (max-width: 1760px) 100vw, 1760px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&#8212;<\/p>\n<p>Java Tutorial on this website: <strong><a href=\"https:\/\/www.testingdocs.com\/java-tutorial\/\">https:\/\/www.testingdocs.com\/java-tutorial\/<\/a><\/strong><\/p>\n<p>For more information on Java, visit the official website :<\/p>\n<p><strong><a href=\"https:\/\/www.oracle.com\/in\/java\/\" rel=\"noopener\">https:\/\/www.oracle.com\/in\/java\/<\/a><\/strong><\/p>\n<!--themify_builder_content-->\n<div id=\"themify_builder_content-2264\" data-postid=\"2264\" class=\"themify_builder_content themify_builder_content-2264 themify_builder tf_clear\">\n    <\/div>\n<!--\/themify_builder_content-->\n","protected":false},"excerpt":{"rendered":"<p>Problem Description Write a Java Program to find the minimum element in an array. We will declare an array with some numbers. Loop each element in the array to find the minimum element in the given array. Java Program \/\/******************************** \/\/MinInArray.java \/\/******************************** public class MinInArray { \/\/main method public static void main(String[] args) { int [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-2264","post","type-post","status-publish","format-standard","hentry","category-java-programs","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/2264","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=2264"}],"version-history":[{"count":6,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/2264\/revisions"}],"predecessor-version":[{"id":21175,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/2264\/revisions\/21175"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=2264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=2264"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=2264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}