Java : Java Stuff!!
Updated: 3/6/2004; 12:54:46 PM.

 

Subscribe to "Java" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.

 
 

Tuesday, March 18, 2003

A small Java pet peeve

Why does the Vector class throw an ArrayIndexOutOfBoundsException when all other List interface implementors throw IndexOutOfBoundsException? Doesn't this somewhat defeat the purpose of encapsulation, since by throwing ArrayIndexOutOfBoundsException, the Vector class is exposing it's internal implementation?? The ArrayList is also based on an array data structure....but it doesn't hint it by throwing the more specific exception. Why can't they deprecate the method and throw the correct exception?

In my humble opinion, no object should throw ArrayIndexOutOfBoundsException because this exception implies the use of an array not the use of an Object.

Sorry for my ranting on such a small insignificant subject....Oh well....What do you think??


5:53:40 PM    comment []

© Copyright 2004 Peter Ghali.



Click here to visit the Radio UserLand website.

 


March 2003
Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Feb   Apr