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

Example Analysis of Java Array Code

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

Share

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

This article is to share with you about the example analysis of Java array code, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Array classification

1. One-dimensional array

1.1 definition and initialization of one-dimensional array

1.2 operations on one-dimensional arrays, traversing, adding, inserting, modifying, deleting, sorting, finding

two。 Two-dimensional array

2.1 definition and initialization of two-dimensional arrays

2.2 traversal of two-dimensional arrays

* / public class ArrayAppend {public static void main (String [] args) {/ / one-dimensional array definition and initialization / / static definition one-dimensional array int [] scores = {90, 70, 50, 80, 60, 85}; / / add a student's score 75 to the end of the one-dimensional array scores. / * ideas: 1. First create a temporary array tempArray 2. 1 that is 1 longer than the original scores array. Copy each value of the scores array to tempArray 3. 0. Then assign a score of 75 to tempArray's new final index position 4. 5. Finally, the tempArray address pointer reference is assigned to scores; * / int [] tempArray = new int [scores.length + 1]; for (int I = 0; I < scores.length; ipointer +) {tempArray [I] = scores [I];} tempArray [scores.length] = 75; scores = tempArray / / printout scores for (int I = 0; I < scores.length; iTunes +) {System.out.print (score [I] + ",");} above is the example analysis of the Java array code. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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: 291

*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