To calculate length of the given array we have used length property. It returns the length of the given array.
public class SizeOfArray { public static void main (String args []) { int num[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; String days[] = {"Sunday","Monday","Tuesday", "Wednesday", "Thursday","Friday","Saturday"}; System.out.println("size of num[]: " + num.length); System.out.println("size of days[]: " + days.length); } }
Output will be displayed as:
Download Source Code
Recommend the tutorial
Ask Questions? Discuss: Get Array Size Post your Comment
Ask Questions? Discuss: Get Array Size
Post your Comment