On Fri, Dec 24, 2010 at 8:12 PM, Mystique <joven.ch...@gmail.com> wrote:
> String[] lv_arr; > > for(int i=1; i<11; i++){ > lv_arr[i] = "hello"; > } > > When I toast the value of lv_arr[i] it is null. > If this is your actual code, you need to initialize the array. String[] lv_arr = new String[11]; Second, array indexing is zero-based, so you would start your loop from 0 and go to 9 (where i < 10). > > If I do this: > > String[] lv_arr = {"hello", hello", "hello"} + the for loop, I can get the > hello value when I do the toast. but [3]-[10] is still null value. > You've initialized an array to exactly three elements. Anything after that (index 3 and above) is non-existent. These are really basic Java concepts. If you don't understand this, I highly recommend you go study Java on it's own and figure this stuff out before trying to do an Android project. You're going to run into a lot of headaches if you try to learn both at the same time. ------------------------------------------------------------------------------------------------- TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en