- 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
Java Program to sort integers in unsorted array
Let us first create an unsorted array −
int[] arr = { 10, 14, 28, 11, 7, 16, 30, 50, 25, 18};
Now assign the unsorted array to the new array −
int[] res = arr; Sorting the integers: Arrays.sort(res);
Example
import java.util.Arrays; public class Demo { public static void main(String[] args) { int[] arr = { 10, 14, 28, 11, 7, 16, 30, 50, 25, 18}; System.out.println("The unsorted integer array = "+Arrays.toString(arr)); int[] res = arr; Arrays.sort(res); System.out.println("The sorted integer array = "+Arrays.toString(res)); } }
Output
The unsorted integer array = [10, 14, 28, 11, 7, 16, 30, 50, 25, 18] The sorted integer array = [7, 10, 11, 14, 16, 18, 25, 28, 30, 50]
- Related Articles
- Write a program in Java to find the missing positive number in a given array of unsorted integers
- Java program to Sort long Array
- Java Program to sort Short array
- Write a program in C++ to find the missing positive number in a given array of unsorted integers
- Java program to create a sorted merged array of two unsorted arrays
- Write a program in C++ to find the maximum and second maximum in a given unsorted array of integers
- Java Program to sort an array in alphabetical order
- Java Program to Sort 2D Array Across Columns
- How to sort an array of integers correctly in JavaScript?
- Java Program to sort an array in case-insensitive order
- Java Program to sort an array in case-sensitive order
- Java Program to Sort Array list in an Ascending Order
- Java Program to Sort the Array Elements in Descending Order
- Finding the largest and smallest number in an unsorted array of integers in JavaScript
- How to sort an array of integers correctly JavaScript?

Advertisements