Last active
August 11, 2018 14:24
-
-
Save ioxua/a55aab8935ca9e1be9b5073a3e8540c8 to your computer and use it in GitHub Desktop.
Érico's Subject
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; | |
import java.util.Scanner; | |
import java.util.stream.Stream; | |
public class Inteirinha { | |
static final int QUANTIDADE_DE_VALORES = 5; | |
public static void main(String ...args) { | |
Scanner ler = new Scanner(System.in); | |
System.out.println("Insira " + QUANTIDADE_DE_VALORES + " valores separados por espaço:"); | |
String[] strings = ler.nextLine().split(" "); | |
strings = Arrays.copyOfRange(strings, 0, QUANTIDADE_DE_VALORES); | |
ler.close(); | |
Integer[] valores = Stream.of(strings).map(Integer::parseInt).toArray(Integer[]::new); | |
Arrays.sort(valores); | |
System.out.println(Arrays.toString(valores)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment