SIZE
Description
- The
SIZE(array)
function is used to calculate and return the number of elements in the array. - The
SIZE(map)
function is used to calculate and return the number of key-value pairs in the map.
Syntax
Parameter Description
array
: Array typearray<T>
, representing the array whose elements need to be counted.map
: Map typemap<K, V>
, representing the map whose key-value pairs need to be counted.
Return Type
Integer (int)
Usage Example
- Count the number of elements in an array:
- Calculate the number of key-value pairs in the mapping:
Notes
- When the passed parameter is not an array or map, the function will return an error.
- If the array or map is empty, the function will return 0.