AHilberink Well-Known Member Licensed User Longtime User May 8, 2014 #1 Hi, I think this will be a simple basic question, but as a beginner I was not able to solve. I need an array, but I don't know how much will be in it. Using: DIM arr() As String will give the error: java.lang.ArrayIndexOutOfBoundsException: length=0; index=0 DIM arr(5) As String works fine, but for only the first 5 and as already mentioned I don't know how much will be in it. Other option I tried was: DIM arr As List but arr.Add expect an List Object, not a string. What can I use best and how (short example will be very welcome ) André
Hi, I think this will be a simple basic question, but as a beginner I was not able to solve. I need an array, but I don't know how much will be in it. Using: DIM arr() As String will give the error: java.lang.ArrayIndexOutOfBoundsException: length=0; index=0 DIM arr(5) As String works fine, but for only the first 5 and as already mentioned I don't know how much will be in it. Other option I tried was: DIM arr As List but arr.Add expect an List Object, not a string. What can I use best and how (short example will be very welcome ) André
Erel B4X founder Staff member Licensed User Longtime User May 8, 2014 #2 Use a List. You can add any object you like to the list, including strings. Upvote 0
AHilberink Well-Known Member Licensed User Longtime User May 8, 2014 #3 Hi Erel, Thanks for the answer. I will use List. I just discover the problem adding a string. I forgot to Initialize the list before use. Stupid of me!! Now it works fine. André Upvote 0
Hi Erel, Thanks for the answer. I will use List. I just discover the problem adding a string. I forgot to Initialize the list before use. Stupid of me!! Now it works fine. André