Java String Length Get length(String s)

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

Description

length

License

Open Source License

Declaration

public static int length(String s) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {

    public static int length(String s) {
        int len = 0;
        for (char c : s.toCharArray()) {
            if (c >= 0x80) {
                len += 2;//w w w.  j  a v  a 2 s  . c o m
            } else {
                len++;
            }
        }
        return len;
    }
}

Related

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