- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What does the method sort(int[] a) do in java?
The sort(int[]) method of the java.util.Arrays class sorts the specified array of integer values into ascending numerical order.
Example
import java.util.Arrays; public class ArrayDemo { public static void main(String[] args) { int iArr[] = {2, 1, 9, 6, 4}; for (int number : iArr) { System.out.println("Number = " + number); } Arrays.sort(iArr); System.out.println("The sorted int array is:"); for (int number : iArr) { System.out.println("Number = " + number); } } }
Output
Number = 2 Number = 1 Number = 9 Number = 6 Number = 4 The sorted int array is: Number = 1 Number = 2 Number = 4 Number = 6 Number = 9
- Related Articles
- What does the method sort(int[] a, int fromIndex, int toIndex) do in java?
- What does the method sort(obj[] a, int fromIndex, int toIndex) do in java?
- What does the method fill(int[], int val) do in java?
- What does the method hashCode(int[] a) do in java?
- What does the method remove(int) do in java?
- What does the method int capacity() do in java?
- What does the method get(int) do in java?
- What does the method equals(int[] a1, int[] a2) do in java?
- What does the method copyOf(int[] original, int newLength) do in java?
- What does the method removeRange(int fromIndex, int toIndex) do in java?
- What does the method fill(int[], int fromIndex, int toIndex, int val) do in java?
- What does the method copyOfRange(int[] original, int from, int to) do in java?
- What does the method elementAt(int index) do in java?
- What does the method removeElementAt(int index) do in java?
- What does the method ensureCapacity(int, minCapacity) do in java?

Advertisements