Last active
March 1, 2020 23:21
-
-
Save wellingtonpgp/ab101fb75a9bcc78a9747057e6c788fd to your computer and use it in GitHub Desktop.
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.ArrayList; | |
import java.util.Arrays; | |
import java.util.Collections; | |
import java.util.List; | |
import java.util.NoSuchElementException; | |
public class Main { | |
public static void main(String[] args) { | |
List<Integer> lista = new ArrayList<>(); | |
lista.addAll(Arrays.asList(2000010, 2000013)); | |
Integer valor = Collections.max(lista); | |
valor++; | |
String novoValor = valor.toString(); | |
String ano = novoValor.substring(0, 2); | |
String numero = novoValor.substring(2, 7); | |
System.out.println(numero + "/" + ano); | |
Integer maior = lista.stream().mapToInt(v -> v).max().orElseThrow(NoSuchElementException::new); | |
maior++; | |
String novoValor2 = maior.toString(); | |
String ano2 = novoValor2.substring(0, 2); | |
String numero2 = novoValor2.substring(2, 7); | |
System.out.println(numero2 + "/" + ano2); | |
// 00014/20 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment