Answers for "how to get size of array java"

7

how to get length of integer in java

int length = (int) (Math.log10(number) + 1);
Posted by: Guest on April-22-2020
2

How to find the length of an array in java

class Main {
  public static void main(String[] args) {
    // Creating an array called x.
    String[] x = new String[]{"This", "Should", "return", "4"};
    // "x.length" finds the length of the array "x".
    System.out.println(x.length);
    // returns 4
  }
}
Posted by: Guest on February-22-2020
0

how to get length of integer in java

int length = 0;
long temp = 1;
while (temp <= number) {
    length++;
    temp *= 10;
}
return length;
Posted by: Guest on April-22-2020

Code answers related to "how to get size of array java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language