Encontramos el arreglo a esta problema, al menos eso creemos. Si presentas inquietudes coméntalo, que sin dudar
Ejemplo 1: cómo añadir elementos en string array en java
Arrays in Java have a defined size, you cannot change it later by adding or removing elements (you can read some basics here).Instead, use a List:ArrayList<String> mylist =newArrayList<String>(); mylist.add(mystring);//this adds an element to the list.
Ejemplo 2: java array añadir elemento
// A better solution would be to use an ArrayList which can grow as you need it. // The method ArrayList.toArray( T[] a ) // gives you back your array if you need it in this form.List<String> where =newArrayList<String>();
where.add(element);
where.add(element);// If you need to convert it to a simple array...String[] simpleArray =newString[ where.size()];
where.toArray( simpleArray );
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)