I want to know that how can i find the number of element in the normal array in java. For example if i have an int array with size 10 and i have inserted only 5 element. Now, i want to check the number of element in my array? Below is the code for more clarification. Please help
public static void main(String[] args) {
int [] intArray = new int[10];
char [] charArray = new char[10];
int count = 0;
for(int i=0; i<=5; i++) {
intArray[i] = 5;
charArray[i] = 'a';
}
for(int j=0; j<=intArray.length; j++) {
if(intArray[j] != null) {
count++;
}
}
System.out.println("int Array element : "+ count);
}