76
Java Program to print the number of elements present in an array
In this program, we need to count and print the number of elements present in the array.
The number of elements present in the array can be found by calculating the length of the array.
Length of above array is 5. Hence, the number of elements present in the array is 5.
Algorithm
- STEP 1: START
- STEP 2: INITIALIZE arr = {1,2,3,4,5}
- STEP 3: PRINT arr.length
- STEP 4: EXIT
Program:
Output:
Number of elements present in given array: 5
Next TopicJava Programs