Lindy Lindqvist wrote:
nil wangad wrote:
how to create dynamic string array if we dont know number of strings in the beginning?
Java has arrays that can grow, like ArrayList.
Pawel Pawlowicz wrote:
Technically, you are wrong. ArrayList is not an array. It is a list.
Lindy Lindqvist wrote:
Pawel Pawlowicz wrote:
Technically, you are wrong. ArrayList is not an array. It is a list.
No I'm technically right and you are nitpickingly wrong.
The ArrayList is a dynamic array implementation part of the Java standard API. Dynamic means it can grow.
Lindy Lindqvist wrote:No I'm technically right and you are nitpickingly wrong.
Pawel Pawlowicz wrote:
No, ArrayList is not an array.
Bear Bibeault wrote:
Lindy Lindqvist wrote:No I'm technically right and you are nitpickingly wrong.
Sorry, but you are not correct. ArrayList is not an array; it is a List implementation. With a List (ArrayList included), you cannot use array indexing, and there is no length property.
Saying that ArrayList is an array is not just technically incorrect, it's even conceptually incorrect.
Paul Clapham wrote:If x is a reference to an ArrayList, and it's an array (according to you), then shouldn't we be able to write "x[2]" and "x.length"? After all you can do that for arrays.
But you can't. So it isn't correct to say an ArrayList is an array. It may well be correct that an ArrayList has an array, but that isn't the same thing. The distinction is well-known in the field of object-oriented design.
Pawel Pawlowicz wrote:
Nope. ArrayList is not an array.
Lindy Lindqvist wrote:
Pawel Pawlowicz wrote:
Nope. ArrayList is not an array.
Yes it is.
ArrayList is a dynamic array implementation and it's as close to a native array as the Java language permits a class to be. And it's part of the standard API.
This means when a static Java array doesn't suit you, first have a look at the ArrayList.
Pawel Pawlowicz wrote:
Technically, static in Java means... Ehhh. Never mind...
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |