I am trying to port some Android 2.x code to Android 1.5, here is the problematic line:
String[] myStringsArray = ...
...
myStringsArray.clear();
String[].clear() is not defined in Android 1.5, leading to this error:
[javac] MyClass.java:1692: cannot find symbol
[javac] symbol : method clear()
[javac] location: class java.lang.String[]
[javac] myStringsArray.clear();
What is the best I could use instead?
You can use the
java.util.Arraysutility class.Arraysprovides a static method calledfill()which takes yourArrayas the first parameter and theObjector primitive to fill the array as the second parameter.You could fill your Array with
nulllike this.Now every position in the Array is null.