Because of items = new String[0];
On Apr 4, 3:48 am, Graham Bright <[email protected]> wrote: > Hi, > > I can't figure out why I am getting and out of bounds exception ? Any > ideas > > Thanks > > public static String[] items = new String[0]; > > public static HashMap<String, String> map = new HashMap<String, > String>(); > > @Override > public void onCreate(Bundle icicle) { > super.onCreate(icicle); > > //sample values for the hash map > map.put("year", "Apple"); > map.put("make", "Mango"); > map.put("model", "Grape"); > map.put("style", "Orange"); > map.put("series", "Peach"); > > Set entries = map.entrySet(); > Iterator entriesIterator = entries.iterator(); > int i=0; > String addEntries = ""; > while(entriesIterator.hasNext()){ > > Map.Entry mapping = (Map.Entry) entriesIterator.next(); > addEntries="" + mapping.getKey() + "" + mapping.getValue(); > items[i] = addEntries; > > i++; > > } > > 04-04 10:44:39.615: WARN/dalvikvm(5258): threadid=3: thread exiting > with uncaught exception (group=0x4001dc20) > 04-04 10:44:39.615: ERROR/AndroidRuntime(5258): Uncaught handler: > thread main exiting due to uncaught exception > 04-04 10:44:39.630: ERROR/AndroidRuntime(5258): > java.lang.RuntimeException: Unable to start activity > ComponentInfo{listmodified.org/listmodified.org.listmodified}: > java.lang.ArrayIndexOutOfBoundsException > 04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at > android.app.ActivityThread.performLaunchActivity(ActivityThread.java: > 2496) > 04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: > 2512) > 04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at > android.app.ActivityThread.access$2200(ActivityThread.java:119) > 04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) > 04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at > android.os.Handler.dispatchMessage(Handler.java:99) > 04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at > android.os.Looper.loop(Looper.java:123) > 04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at > android.app.ActivityThread.main(ActivityThread.java:4363) > 04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at > java.lang.reflect.Method.invokeNative(Native Method) > 04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at > java.lang.reflect.Method.invoke(Method.java:521) > 04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at > com.android.internal.os.ZygoteInit > $MethodAndArgsCaller.run(ZygoteInit.java:862) > 04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620) > 04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at > dalvik.system.NativeStart.main(Native Method) > 04-04 10:44:39.630: ERROR/AndroidRuntime(5258): Caused by: > java.lang.ArrayIndexOutOfBoundsException > 04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at > listmodified.org.listmodified.onCreate(listmodified.java:72) > 04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at > android.app.Instrumentation.callActivityOnCreate(Instrumentation.java: > 1047) > 04-04 10:44:39.630: ERROR/AndroidRuntime(5258): at > android.app.ActivityThread.performLaunchActivity(ActivityThread.java: > 2459) > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

