tirar zeros array
Pessoal to com esse codigo
//FUNCAO PARES
public static int[] pares(int array[]){
//int pares[] = null;
//CODIGO DA QUESTAO 03
int[] pares = new int[array.length];
for (int i = 0; i < array.length; i++){
if (array[i]%2==0){
pares[i]=array[i];
}
}
return pares;
}
era pra retornar so os paras mas ta retornando
0, 2, 0, 4, 0, 6, 0, 8, 0, 10
como tirar os zeros?
//FUNCAO PARES
public static int[] pares(int array[]){
//int pares[] = null;
//CODIGO DA QUESTAO 03
int[] pares = new int[array.length];
for (int i = 0; i < array.length; i++){
if (array[i]%2==0){
pares[i]=array[i];
}
}
return pares;
}
era pra retornar so os paras mas ta retornando
0, 2, 0, 4, 0, 6, 0, 8, 0, 10
como tirar os zeros?
Valdemi Ramos
Curtidas 0
Respostas
Dyego Carmo
21/08/2010
Crie um SET , assim nao vai mais haver duplicados...
Set<Integer> numeros = new LinkedHashSet<Integer>();
Set<Integer> numeros = new LinkedHashSet<Integer>();
GOSTEI 0
Valdemi Ramos
21/08/2010
valew
GOSTEI 0