Last active
September 21, 2023 01:20
-
-
Save GuMilano/25a133758b2a2ee0585b37bc7cf0245c to your computer and use it in GitHub Desktop.
ArraySort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package github; | |
import java.util.Arrays; | |
/** | |
*O java.util.Arrays usa quicksort para tipos primitivos como int e | |
* mergesort para objetos que implementam Comparable ou usam um Comparator. | |
*/ | |
public class ArraySort { | |
//i se inicia com valor inicial 0 | |
//Enquanto i for menor que que o comprimento da matriz, executa a saída com os nomes dos países até se encerrar a matriz | |
public static void main(String[] args) { | |
String[] countries = {"India","United States","Malaysia","Australia","Lundon"}; | |
Arrays.sort(countries); | |
for(int i = 0; i < countries.length; i++) { | |
System.out.println(countries[i]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment