- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcount.java
More file actions
Latest commit
15 lines (11 loc) · 427 Bytes
/
Copy pathcount.java
File metadata and controls
15 lines (11 loc) · 427 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//this program counts number of elements in an array
publicclasscount {
publicstaticvoidmain(String[] args) {
// Initialize array
int[] arr = {1, 2, 3, 4, 5};
// Get the number of elements using length
intelementsCount = arr.length;
// Print the number of elements
System.out.println("Number of elements present in the array: " + elementsCount);
}
}