Using COUNT
The COUNT returns the number of elements that a collection presently contains. For instance, when a varray projects contains 15 elements, then the following IF condition is true:
IF projects.COUNT = 15 THEN...
The COUNT is very useful as the present size of a collection is not always known. For e.g. if you fetch a column of the Oracle data into a nested table, then how many elements does the table contain? The COUNT provides you the answer.
You can also use the COUNT where an integer expression is allowed. In the next e.g. you use COUNT to specify the upper bound of a loop range:
FOR i IN 1..courses.COUNT LOOP ...
For the varrays, the COUNT is always equals to LAST. For nested tables, COUNT generally equals to LAST. But, if you delete elements from the middle of a nested table, then the COUNT becomes smaller than LAST.