I have a static array which is: String[] tab = {"Eva", "Ali", "David", "Maxime"};
If the name is bigger that 4 characters I have to put the items in another array. I know how to do this with an arraylist, but I want to try with a static array.
Here is an idea of my code but I am stuck in my loop.
class Main {
public static void main(String[] args) {
String[] tab = {"Eva", "Ali", "David", "Maxime"};
for (String elt : tab) {
if (elt.length() > 4) {
// ????
}
}
}
}
Thank you for your help.
nullOR 2) You can rebuild the array OR 3) You could keep valid values in aListand rebuild the "valid" array at the end. It is up to youList#addandanotherArray[i++]and to replace thefor-eachwith a plainfor