Java String Length Get length(Object string)

Here you can find the source of length(Object string)

Description

length

License

Open Source License

Declaration

public static final int length(Object string) 

Method Source Code

//package com.java2s;
/*/*from  w  w  w . ja  v  a2s  .  c  o  m*/
 * This file is part of the Jose Project
 * see http://jose-chess.sourceforge.net/
 * (c) 2002-2006 Peter Sch?fer
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 */

public class Main {
    public static final int length(Object string) {
        if (string instanceof String)
            return ((String) string).length();
        if (string instanceof StringBuffer)
            return ((StringBuffer) string).length();
        throw new IllegalArgumentException("expecting String or StringBuffer");
    }
}

Related

  1. length(final String s)
  2. length(final String s, final String separator)
  3. length(String arg)
  4. length(String buffer)
  5. length(String s)
  6. length(String s)