提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
Java StringBuffer类的int length()方法返回StringBuffer对象的长度。
public class Main {/** 来 自 N o w J a v a . c o m**/ public static void main(String[] args) { StringBuffer sb = new StringBuffer("Hello World"); int len = sb.length(); System.out.println("Length of a StringBuffer object is : " + len); } }