• matthew@hierthinking.com

Forum

Forum breadcrumbs - You are here:Hier Thinking ForumProgramming: Javaarray length
Please or Register to create posts and topics.

array length

int arr1[]= {1 ,2, 1, 4, 2, 3, 5, 4, 3, 2, 1};

int arr2[]= {arr1.length};

System.out.println(arr1.length);

System.out.println(arr2.length);

Output

11

1

Why get the different length value please explain

arr2 has a single element, the length of arr1.

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/arrays