Convert ArrayList to Array throws java.lang.ArrayStoreException

i have a method `convertToArray()` which converts an `ArrayList` to an array. I want to call this method every time an element is added to the `ArrayList`. public class Table extends ArrayList { public String appArray[]; //Array of single applicant details public String tableArray[][]; //Array of every applicant /** * Constructor for objects of class Table */ public Table() { } public void addApplicant(Row app) { add(app); convertToArray(); } public void convertToArray() { int x = size(); appArray=toArray(new String[x]); } } When i call the `addApplication(Row app)` method I get the error: `java.lang.ArrayStoreException` So I changed my `addApplicant()` method to: public void addApplicant(Row app) { add(app); if (size() != 0) convertToArray(); } I get the same error message. Any ideas why? I figured if it checks the `ArrayList` has elements before converting it the error should not be thrown? I can provide the full error if needed
it might help you stackoverflow.com/questions/8849163/…

以上就是Convert ArrayList to Array throws java.lang.ArrayStoreException的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏