[Info-vax] Simple Pascal question
Arne Vajhøj
arne at vajhoej.dk
Thu Sep 5 13:30:44 EDT 2024
On 8/4/2024 9:58 PM, Dan Cross wrote:
> In article <v8p87j$9ptm$3 at dont-email.me>,
> Arne Vajhøj <arne at vajhoej.dk> wrote:
>> On 8/4/2024 8:09 PM, Dan Cross wrote:
>>> In article <v8o4h8$2ut3$1 at dont-email.me>,
>>> Arne Vajhøj <arne at vajhoej.dk> wrote:
>>>> Like:
>>>>
>>>> public class FlexArray {
>>>> private static void dump(int[] a) {
>>>> for(int v : a) {
>>>> System.out.printf(" %d", v);
>>>> }
>>>> System.out.println();
>>>> }
>>>> public static void main(String[] args) throws Exception {
>>>> int[] a1 = { 1 };
>>>> int[] a2 = { 1, 2 };
>>>> int[] a3 = { 1, 2, 3 };
>>>> dump(a1);
>>>> dump(a2);
>>>> dump(a3);
>>>> }
>>>> }
>>>
>>> Java arrays are more like the aforementioned slices.
>>
>> I don't think so.
>>
>> Java does not have anything like slices.
>
> An array in Java is a pointer and a length. A slice is a
> pointer and a length.
An array in Java is an object containing data type, array
length and all the elements.
Which is not the same as a structure containing a
pointer to somewhere in another object and a length.
Arne
More information about the Info-vax
mailing list