Ver Mensaje Individual
  #2 (permalink)  
Antiguo 05/08/2015, 00:31
Avatar de Profesor_Falken
Profesor_Falken
 
Fecha de Ingreso: agosto-2014
Ubicación: Mountain View
Mensajes: 1.323
Antigüedad: 9 años, 9 meses
Puntos: 182
Respuesta: Arrays y eliminar posicion

Buenas,

Una posible implementacion rapida:

Código Java:
Ver original
  1. public static void main(String[] args) {
  2.         String[] valores = {"uno", "dos", "tres"};
  3.  
  4.         System.out.println(Arrays.toString(valores));
  5.  
  6.         removeIndex(valores, 0);
  7.  
  8.         System.out.println(Arrays.toString(valores));
  9.     }
  10.  
  11.     private static void removeIndex(String[] array, int index) {
  12.         int i = index;
  13.         for (; i < array.length - 1; i++) {
  14.             array[i] = array[i + 1];
  15.         }
  16.         array[i] = null;
  17.     }

Un saludo
__________________
If to err is human, then programmers are the most human of us