remove all elements in an String[]

how to remove all the elements from String[]?Thanks.
[66 byte] By [Rxyza] at [2007-10-2 20:21:31]
# 1
Here's one way. Just re-create the instance.String[] strArray = ....;..........................strArray = new String[arraySize];
suppusa at 2007-7-13 23:04:02 > top of Java-index,Java Essentials,New To Java...
# 2
create a new one.myArray = new String[numValues];
BaltimoreJohna at 2007-7-13 23:04:02 > top of Java-index,Java Essentials,New To Java...
# 3

If your not restricted, you could use an ArrayList of strings like:

ArrayList <String> al = new ArrayList <String> ();

To add strings to the arraylist, just use the add method.

al.add("C");

al.add("A");

al.add("E");

al.add("B");

al.add("F");

al.add("D");

al.add(0, "F");

then you can do the following to remove all the elements:

al.clear();

Java_Jaya at 2007-7-13 23:04:02 > top of Java-index,Java Essentials,New To Java...
# 4
> how to remove all the elements from String[]?You can't.The number of elements in an array is fixed at creation and cannot be changed.
jverda at 2007-7-13 23:04:02 > top of Java-index,Java Essentials,New To Java...