Search code examples
javaprogramming-languageslanguage-design

Why exactly are Java arrays not expansible?


Possible Duplicate:
Why aren’t arrays expandable?

I am starting to learn Java as my Computer Science school's assignments require this language and I'm liking the language. However, I've seen that Java arrays are not expansible - that is - you must declare their length before using them and it can't be changed further.

I'd like to know exactly why is that? Why the Java language designers chose to to make arrays as such? I guess it's for performance concerns but I'm not sure.

Thanks everyone in advance.


Solution

  • I'd like to know exactly why is that? Why the Java language designers chose to to make arrays as such? I guess it's for performance concerns but I'm not sure.

    They designed primitives and arrays to be as simple and low level as possible. They don't do anything special and arrays don't use Object Orientated design at all. i.e. they only have a few useful methods, none specific to arrays.

    The idea was that you would write higher level collections such as Lists using these low level constructs.