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
import java.util.Arrays; | |
public class OrdenarArreglos { | |
public static void main(String[] args) { | |
int numeros[] = {1, 9, 23, 4, 55, 100, 1, 1, 23}; | |
System.out.println("Antes de ordenar: " + Arrays.toString(numeros)); | |
// Ordenar. Modifica internamente al arreglo | |
Arrays.sort(numeros); | |
System.out.println("Después de ordenar: " + Arrays.toString(numeros)); | |
// Otro ejemplo con cadenas | |
String nombres[] = {"Luis", "María", "Pedro", "Angela", "Elliot", "Mobley"}; | |
System.out.println("Antes de ordenar: " + Arrays.toString(nombres)); | |
// Ordenar. Modifica internamente al arreglo | |
Arrays.sort(nombres); | |
System.out.println("Después de ordenar: " + Arrays.toString(nombres)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment