Java String Length Get length(String str)

Here you can find the source of length(String str)

Description

Gets a String's length or 0 if the String is null.

License

Open Source License

Parameter

Parameter Description
str a String or <code>null</code>

Return

String length or 0 if the String is null.

Declaration

public static int length(String str) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*w  w  w. j  av  a2s. c o  m*/
     * Gets a String's length or <code>0</code> if the String is <code>null</code>.
     *
     * @param str
     *            a String or <code>null</code>
     * @return String length or <code>0</code> if the String is <code>null</code>.
     * @since 2.4
     */
    public static int length(String str) {
        return str == null ? 0 : str.length();
    }
}

Related

  1. length(String s)
  2. length(String s)
  3. length(String schema)
  4. length(String source)
  5. length(String str)
  6. length(String str)
  7. length(String string)
  8. length(String string)
  9. length(String... args)