GoConqr has a new look! Let us know what you think.

Notes

Sorting an Array

Olivia B English 1 page

Content of the notes (1)

Page 1

import java.util.Arrays;

public static void main (String[] args)

{

int[] ints = new int[10]; //creates array of 10 elements

for(int i=0; i < ints.length; i++)

{

ints[i] = 10 - i; //initializes array

}

System.out.println("Before: " + java.util.Arrays.toString(ints)); //print before sort

Arrays.sort(ints); //call sort method

System.out.println("After: " + java.util.Arrays.toString(ints)); //print after sort

}

//Output//

Before: [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]

After: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Information

Description
Note on Sorting an Array, created by Olivia B on 01/06/2018.
Created by
Olivia B
Views
1
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?