Storing Result set into an array

前端 未结 2 1244
闹比i
闹比i 2020-12-17 00:51

i know this should be simpel and im probably staring straight at the problem but once again im stuck and need the help of the code gurus.

im trying too take one row

2条回答
  •  太阳男子
    2020-12-17 01:42

    You should use an ArrayList which provides all the logic to automatically extend the array.

    List rowValues = new ArrayList();
    while (namesList.next()) {
        rowValues.add(namesList.getString(1));
    }   
    // You can then put this back into an array if necessary
    contactListNames = (String[]) rowValues.toArray(new String[rowValues.size()]);
    

提交回复
热议问题