Ver Mensaje Individual
  #9 (permalink)  
Antiguo 20/04/2010, 15:03
Avatar de xlugo2002
xlugo2002
 
Fecha de Ingreso: noviembre-2002
Ubicación: Puebla, México
Mensajes: 474
Antigüedad: 21 años, 6 meses
Puntos: 0
Respuesta: Problema eliminando elemento de un ArrayList

import java.util.ArrayList;
import java.util.Iterator;

public class Metodos {

private static ArrayList<String> modifica(ArrayList<String> arreglo){
arreglo.add("seis");
int u=1;

Iterator it = arreglo.iterator();

while(it.hasNext()){
String cad = (String) it.next();
if(cad.equals("uno"))
it.remove();
}


return arreglo;
}


public static void main(String[] args){

int a = 10;
ArrayList<String> arreglo = new ArrayList<String>();

arreglo.add("uno");
arreglo.add("dos");
arreglo.add("tres");
arreglo.add("cuatro");
arreglo.add("cinco");

ArrayList<String> arreglol = modifica(arreglo);

for(String iten : arreglol){
System.out.println(iten + "<br>");
}



}




}