1
Reply

bug in ArrayLists?

said7effo

said7effo

Nov 14 2003 12:58 PM
1.9k
Greetings, I spent 10 minutes figuring out the weirdest bug. I declared an arraylist in a class without initializing it. In the constructor i did the fatal mistake of redeclaring the arraylist instead of initializing it i.e: ArrayList myArrayList_ = new ArrayList(); instead of myArrayList_ = new ArrayList(); A class function uses the myArrayList_ private object. When it tried to add new elements to the arraylist, no exceptions were thrown, the windows forms thread continued execution as if i didn't do the call to the method of the class. And obviously, the object containing the arraylist wasn't initialized as intended. Does anyone have an idea how adding elements to an unitialized arraylist doesn't generate a runtime exception? (btw, the function call that adds items to the arraylist was done through a custom data load event). Thanks

Answers (1)