{"id":284,"date":"2013-08-26T06:19:07","date_gmt":"2013-08-26T06:19:07","guid":{"rendered":"http:\/\/codethataint.com\/blog\/?p=284"},"modified":"2013-08-26T06:19:07","modified_gmt":"2013-08-26T06:19:07","slug":"how-to-remove-last-element-from-array-java","status":"publish","type":"post","link":"https:\/\/codethataint.com\/blog\/how-to-remove-last-element-from-array-java\/","title":{"rendered":"How to remove last element from array Java"},"content":{"rendered":"<p>How to remove last element in a array and store it in same Array<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\"> \r\nimport java.util.Arrays;\r\n\r\npublic class SimpleArray \r\n{\r\n  public static void main(String&#x5B;] args) \r\n  {\r\n    String&#x5B;] arrNames1 = {&quot;Mugil&quot;, &quot;Mani&quot;, &quot;Vinu&quot;, &quot;Shivaji&quot;, &quot;Raman&quot;};\r\n    String&#x5B;] arrNames2 = new String&#x5B;arrNames1.length-1]; \r\n\t\t\r\n    for(int i=0;i&lt;arrNames1.length-1;i++)\r\n      arrNames2&#x5B;i] = arrNames1&#x5B;i];\r\n\t\t\r\n    arrNames1 = arrNames2.clone();\r\n\t\t\r\n    for (int i = 0; i &lt; arrNames1.length; i++) \r\n      System.out.println(arrNames1&#x5B;i]);\t\t\r\n  }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>How to remove last element in a array and store it in same Array import java.util.Arrays; public class SimpleArray { public static void main(String&#x5B;] args) { String&#x5B;] arrNames1 = {&quot;Mugil&quot;, &quot;Mani&quot;, &quot;Vinu&quot;, &quot;Shivaji&quot;, &quot;Raman&quot;}; String&#x5B;] arrNames2 = new String&#x5B;arrNames1.length-1]; for(int i=0;i&lt;arrNames1.length-1;i++) arrNames2&#x5B;i] = arrNames1&#x5B;i]; arrNames1 = arrNames2.clone(); for (int i = 0; i &lt; arrNames1.length;&hellip; <a href=\"https:\/\/codethataint.com\/blog\/how-to-remove-last-element-from-array-java\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51],"tags":[],"class_list":["post-284","post","type-post","status-publish","format-standard","hentry","category-arrays"],"_links":{"self":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/284","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/comments?post=284"}],"version-history":[{"count":1,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/284\/revisions"}],"predecessor-version":[{"id":285,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/284\/revisions\/285"}],"wp:attachment":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/media?parent=284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/categories?post=284"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/tags?post=284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}