{"id":1353,"date":"2022-03-03T07:22:03","date_gmt":"2022-03-03T07:22:03","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=1353"},"modified":"2022-03-03T07:22:03","modified_gmt":"2022-03-03T07:22:03","slug":"largest-element-of-an-array","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/03\/03\/largest-element-of-an-array\/","title":{"rendered":"Largest Element of an Array"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Find the largest element in an array<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>public class Largest {\n\n    public static void main(String&#91;] args) {\n        double&#91;] numArray = { 23.4, -34.5, 50.0, 33.5, 55.5, 43.7, 5.7, -66.5 };\n        double largest = numArray&#91;0];\n\n        for (double num: numArray) {\n            if(largest &lt; num)\n                largest = num;\n        }\n\n        System.out.format(\"Largest element = %.2f\", largest);\n    }\n}<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><samp>Largest element = 55.50<\/samp><\/code><\/pre>\n\n\n\n<p>In the above program, we store the first element of the array in the variable&nbsp;<var>largest<\/var>.<\/p>\n\n\n\n<p>Then,&nbsp;<var>largest<\/var>&nbsp;is used to compare other elements in the array. If any number is greater than&nbsp;<var>largest<\/var>,&nbsp;<var>largest<\/var>&nbsp;is assigned the&nbsp;<var>number<\/var>.<\/p>\n\n\n\n<p>In this way, the largest number is stored in&nbsp;<var>largest<\/var>&nbsp;when it is printed.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Find the largest element in an array Output In the above program, we store the first element of the array in the variable&nbsp;largest. Then,&nbsp;largest&nbsp;is used to compare other elements in the array. If any number is greater than&nbsp;largest,&nbsp;largest&nbsp;is assigned the&nbsp;number. In this way, the largest number is stored in&nbsp;largest&nbsp;when it is printed.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[403],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1353"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=1353"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1353\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=1353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=1353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=1353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}