StringBuilder类的length()方法 (StringBuilder Class length() method)

  • length() method is available in java.lang package.

    length()方法在java.lang包中可用。

  • length() method is used to return the length of this sequence (i.e. it counts the number of characters denoted by this object).

    length()方法用于返回此序列的长度(即,它计算此对象表示的字符数)。

  • length() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    length()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • length() method does not throw an exception at the time of returning length.

    length()方法在返回length时不会引发异常。

Syntax:

句法:

    public int length();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of this method is int, it returns the counts of the number of characters stored in this object.

此方法的返回类型为int ,它返回存储在此对象中的字符数的计数。

Example:

例:

// Java program to demonstrate the example
// of int length() method of StringBuilder
public class Length {public static void main(String[] args) {// Creating an StringBuilder object
StringBuilder st_b = new StringBuilder("Java World ");
// Display st_b
System.out.println("st_b = " + st_b);
// By using length() method is to return the length
// of st_b object
int len = st_b.length();
// Display st_b length
System.out.println("st_b.length() = " + len);
}
}

Output

输出量

st_b = Java World
st_b.length() = 11

翻译自: https://www.includehelp.com/java/stringbuilder-length-method-with-example.aspx

Java StringBuilder length()方法与示例相关推荐

  1. Java IOUtils.copy方法代码示例(亲测)

    本文整理汇总了Java中org.apache.commons.io.IOUtils.copy方法的典型用法代码示例.如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java I ...

  2. setlength java_Java StringBuilder setLength()方法与示例

    StringBuilder类setLength()方法setLength()方法在java.lang包中可用. setLength()方法用于在将字符序列替换为新字符序列时设置字符序列的长度,因此该序 ...

  3. java size_Java length() 方法,length 属性和 size() 方法的区别

    豆妮的小奴隶 length() 方法,length 属性和 size() 方法的区别: 1.length()方法是针对字符串来说的,要求一个字符串的长度就要用到它的length()方法: 2.leng ...

  4. java fst 入门 例子,Java FST.save方法代码示例

    import org.apache.lucene.util.fst.FST; //导入方法依赖的package包/类 /** * * @param inputStream the input stre ...

  5. java codepointbefore_Java StringBuilder codePointBefore()方法与示例

    StringBuilder类codePointBefore()方法codePointBefore()方法在java.lang包中可用. codePointBefore()方法用于表示给定索引和数组索引 ...

  6. java user directory,Java ProcessBuilder directory()方法与示例

    语法:public File directory (); public ProcessBuilder directory (File dir); ProcessBuilder类directory()方 ...

  7. java path util,Java URIUtil.canonicalPath方法代码示例

    import org.eclipse.jetty.util.URIUtil; //导入方法依赖的package包/类 /** Get the resource list as a HTML direc ...

  8. Java序列化魔术方法及其示例使用

    在上一篇文章中, 您需要了解有关Java序列化的所有知识 ,我们讨论了如何通过实现Java序列化来启用类的可序列化性. Serializable接口. 如果我们的类未实现Serializable接口, ...

  9. catalog java,Java Connection getCatalog()方法与示例

    通常,目录是一个目录,其中包含有关数据集,文件或数据库的信息.而数据库目录中包含所有数据库,基本表,视图(虚拟表),同义词,值范围,索引,用户和用户组的列表. Connection接口的getCata ...

最新文章

  1. jsp 实栗 jsp + jdbc 登录
  2. vue 高阶面试题_高级Web前端工程师面试之Vue问题汇总解析
  3. android.hardware.camera2使用指南
  4. 实现vue2.0响应式的基本思路
  5. Java黑皮书课后题第6章:*6.21(电话按键盘)国际标准的字母/数字匹配图如编程练习题4.15所示。编写一个测试程序,提示用户输入字符串形式的电话号码。程序将字母(大写或小写)翻译成数字
  6. python函数参数为类对象_将Cython类对象作为参数传递给C函数
  7. flex组件使用【PopUpButton】
  8. 51单片机的io口可不可以接gnd_纯干货!简析单片机中的高阻态
  9. Linux中查看socket进程状态
  10. paip.中文 分词 ---paoding 3.1 的使用
  11. 在CentOS 8上安装使用Firefox的视频播放功能(FFmpeg)
  12. 终止python程序的死循环_终的解释|终的意思|汉典“终”字的基本解释
  13. python rgb颜色表_[置顶] RGB颜色查询对照表
  14. 算法之美_源码公布(1)
  15. 随笔记:实现HTML页面局部滚动及自定义滚动条样式
  16. SAP MM库存盘点流程
  17. 什么情况下你会毫不犹豫地辞职?
  18. GitHub 入门教程
  19. 极路由设置虚拟服务器,HiWiFi极路由手机设置教程
  20. 七牛云这个API,让我轻松搞定Banner背景自动切换的功能

热门文章

  1. webpack 入口文件 php,如何实现webpack多入口文件打包配置
  2. java 程序找错_java代码找错
  3. java treetable_在Swing中创建TreeTable | 学步园
  4. 关于Linux网卡调优之:RPS (Receive Packet Steering)
  5. ES6之主要知识点(二) 变量的解构赋值。默认值
  6. Linux相关图解随记
  7. java多线程总结(二)
  8. 第一百四十一节,JavaScript,封装库--DOM加载
  9. LAMP平台架构浅析
  10. linux虚拟光驱挂载方法,Linux操作系统下虚拟光驱(iso)的挂载