how to get size of array java code example

Example 1: how to get length of integer in java

int length = (int) (Math.log10(number) + 1);

Example 2: how to find length of array in java

let coolCars = ['ford', 'chevy'];
//to find length, use the array's built in method
let length = coolCars.length;
//length == 2.

Example 3: how to get length of integer in java

int length = 0;
long temp = 1;
while (temp <= number) {
    length++;
    temp *= 10;
}
return length;

Example 4: java get size of array

arrayname.length

Tags:

C Example