Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to delete the value of the scores array index index position in the Java array

2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

It is believed that many inexperienced people do not know what to do about how to delete the value of the index position of the scores array index in the Java array. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

/ * * title: delete the value of scores array index index position: 1. Create a temporary array tempArray 2. 0 that is 1 smaller than scores. Copy the data in front of index to the front of tempArray 3. 0. Copy the array after index to 4. 0 after tempArray. Assign the tempArray address pointer reference to scores 5. 0. Printout scores*/import java.util.Scanner;public class ArrayDelete {public static void main (String [] args) {/ / definition and initialization of one-dimensional array int [] scores = {90, 70, 50, 80, 60, 85}; System.out.println ("Please enter the index index:") Scanner in = new Scanner (System.in); int index = in.nextInt (); / / 1. Create a temporary array tempArray int [] tempArray = new int [scores.length-1] that is 1 smaller than scores; / / 2. Copy the data in front of index to the front of tempArray / / 3. Copy the array after index to for after tempArray (int I = 0; I

< scores.length; i++) { if (i < index) tempArray[i] = scores[i]; if (i >

Index) tempArray [I-1] = scores [I];} / / 4. Assign the tempArray address pointer reference to scores scores = tempArray; / / 5. Printout scores for (int I = 0; I < scores.length; iTunes +) {System.out.print (score [I] + ",")} after reading the above, do you know how to delete the value of the index index position of the scores array in the Java array? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report