0

What is array length?

Array Length

29th Nov 2016, 12:18 AM
Irah Singson
Irah Singson - avatar
2 Answers
+ 2
A Java array length example. ... Answer: While you might logically expect there to be a length method on a Java array, there is actually a public length attribute on an array (instead of a length method). Therefore, to get the Java array length, you just have to access this array length attribute.
29th Nov 2016, 1:05 AM
Abdelaziz Abubaker
Abdelaziz Abubaker - avatar
+ 1
Array length is the cardinality of the array. var firstArray = ["a", "Test", 5]; var secondArray = ["a", true, 5, 't', 2.0]; firstArray.length would return the integer 3 since there are 3 elements. string "a", string "Test" and the integer 5 secondArray.length would return the integer 5 since there are 5 elements. string "a", boolean true, integer 5, char 't' and double 2.0 for sure you could assign them to variables like: var firstInt = firstArray.length; var secondInt = secondArray.length; console.log(firstInt) would print 3 console.lig(secondInt) would print 5
29th Nov 2016, 12:46 AM
ordens
ordens - avatar