user45678 user45678 - 4 months ago 17
Android Question

How to add last item empty into a list of dynamic array

I have a dynamic array of list into which i want to add last item as " " (empty). Something like this :

list.add("Test");
list.add("Working");
list.add("");


I tried below code, but that doesn't seem to work, any idea

for (int k = 0; k <arraysize; k++) {

list.add(getlist().get(k));
if(k == -1){
list.add("");
}

}

Answer Source
for (int k = 0; k <arraysize; k++) {

                    list.add(getlist().get(k));
                    if(k == arraysize-1){
                        list.add("");
                    }

}