Skip to content

Instantly share code, notes, and snippets.

@ioxua
Last active August 11, 2018 14:24
Show Gist options
  • Save ioxua/a55aab8935ca9e1be9b5073a3e8540c8 to your computer and use it in GitHub Desktop.
Save ioxua/a55aab8935ca9e1be9b5073a3e8540c8 to your computer and use it in GitHub Desktop.
Érico's Subject
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