How to Sort 3 Integers in Java

104 38
    • 1). Create a new file in your Java development program.

    • 2). Type the following at the top of the file in your text editor:

      import java.util.Arrays;

      Java.util.Arrays contains a method that will be used to sort an array of integers.

    • 3). Create an array of three integers, as in the following example:

      int[] array = new int[] {3, 1, 2};

    • 4). Sort the array using the Arrays.sort method by typing the following:

      Arrays.sort(array);

      The Array.sort method sorts the integers in the array by ascending order.

Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.