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

An example Analysis of sorting AJPFX in arrays Array of java

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

In this issue, the editor will bring you an example analysis of java's arrays array sorting AJPFX. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Java API's description of the Arrays class is that it contains various methods for manipulating arrays, such as sorting and searching.

1. Sort arrays of basic data types

Description:

(1) sort () in the Arrays class uses the "tuned fast sorting method"

(2) for arrays of base data types such as int [], double [], char [], the Arrays class only provides the default ascending order, but does not provide the corresponding descending order method.

(3) to sort arrays of basic types in descending order, you need to convert these arrays into corresponding arrays of encapsulated classes, such as Integer [], Double [], Character [], and so on. (in fact, it is better to sort in ascending order first, and you are turning to the order.)

Sort the array with the default ascending order

Function prototype: static void sort (int [] a) sorts the specified int array in ascending numerical order.

Static void sort (int [] a, int fromIndex, int toIndex) sorts the specified range of the specified int array in ascending numerical order.

Code example:

[url=] copy code [/ url] code is as follows:

Import java.util.Arrays

Public class ArraysSort_11 {

Public static void main (String args [])

{

Int [] a = {1pyrrine 4 maestrine 5pyrr0}

Arrays.sort (a)

/ / the content of the array a [] is changed to {- 1Jing 0Jing 1JI 4JI 5}.

For (int iTuno Bandi)

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