One-dimensional array of Java arrays delete elements

Source: Internet
Author: User

http://www.verejava.com/?id=16992656053526

/* Title: Delete Scores array index value idea of index position: 1. Create a temporary array Temparray 2 that is temporarily 1 smaller than scores. Copy the data in front of index to Temparray in front of 3. Copy the array after index to Temparray after 4. Assigns a Temparray address pointer reference to scores 5. Print output Scores*/import Java.util.scanner;public class arraydelete{public static void Main (string[] args) {//one-dimensional number        Definition and initialization of the group int[] scores={90,70,50,80,60,85};        System.out.println ("Please enter the index to delete:");        Scanner in=new Scanner (system.in);        int Index=in.nextint (); 1.        Create a temporary array that is temporarily 1 smaller than scores temparray int[] Temparray=new int[scores.length-1]; 2. Copy the data in front of index to Temparray front//3.                Copy the array after index to Temparray after for (int i=0;i<scores.length;i++) {if (I<index)            Temparray[i]=scores[i];        if (I>index) temparray[i-1]=scores[i]; }//4.        Assigns the Temparray address pointer reference to the scores scores=temparray; 5. Print output scores for (int i=0;i<scores.length;i++) {System.out.print (scOres[i]+ ","); }    }}

http://www.verejava.com/?id=16992656053526

One-dimensional array of Java arrays delete elements

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.