Bom dia.
Estou tentando executar uma lógica para imprimir no console, uma lista de nr de apartamentos.
No exercicio, o apartamento tem 10 andares, 2 apto por andar e sua numeração deve começar com 101.
A resposta seria:
101, 102
201,202
301,302
Porém estou errando feio e aparece só 101,101,101… , por favor, poderiam me ajudar nesse problema:
Meu código:
import java.util.ArrayList;
import java.util.List;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author gtalkSP
*/
public class ImprimeListaApto{
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Integer nrApto = 100;
Integer andares = 10;
Integer aptoPorAndar = 2;
List lista = new ArrayList();
for (int i = 1; i < andares; i++) {
for (int j = 1; j < aptoPorAndar; j++) {
Integer zz = nrApto + j;
lista.add(zz);
for(int l = 0; l < lista.size(); l++ ){
System.out.println("Apto nr: "+lista.get(l));
}
}
}
}
}