Java String Length Get length(String str)

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

Description

length

License

LGPL

Declaration

public static int length(String str) 

Method Source Code

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

public class Main {

    public static int length(String str) {
        if (str == null)
            return 0;
        char[] c = str.toCharArray();
        int len = 0;
        for (int i = 0; i < c.length; i++) {
            len++;//from   w  w w .jav a 2 s  . c  o  m
            if (!isLetter(c[i])) {
                len++;
            }
        }
        return len;
    }

    private static boolean isLetter(char charStr) {
        int k = 0x80;
        return charStr / k == 0 ? true : false;
    }
}

Related

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