Java Array Length Get length(String[] arr)

Here you can find the source of length(String[] arr)

Description

length

License

Apache License

Declaration

public static int length(String[] arr) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static int length(byte[] bytes) {
        if (bytes == null)
            return 0;
        return bytes.length;
    }//from w w w .  jav  a  2 s  .c  o m

    public static int length(byte[][] bytes) {
        if (bytes == null)
            return 0;
        int count = 0;
        for (int i = 0; i < bytes.length; i++) {
            if (bytes[i] != null)
                count += bytes[i].length;
        }
        return count;
    }

    public static int length(String str) {
        if (str == null)
            return 0;
        return str.length();
    }

    public static int length(String[] arr) {
        if (arr == null || arr.length == 0)
            return 0;
        int sum = 0;
        for (String s : arr)
            sum += length(s);
        return sum;
    }
}

Related

  1. length(Object anArray[])
  2. length(Object[] array)
  3. length(Object[] array)
  4. length(Object[] array)
  5. length(Object[] buf)
  6. length(T[] a)
  7. length3(float[] a)
  8. lengthArray(Object[][] arr)
  9. lengthCheck(double[] src, double[] dest)