8/6

本文详细介绍了 Java 中 StringBuffer 类的 setLength() 方法的用法,包括如何设置字符序列的长度,并提供了具体示例代码。此外,还涉及了多线程、RecyclerView 的使用技巧等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

java.lang.StringBuffer.setLength() 方法设置字符序列的长度。该序列被改变到一个新的字符序列的参数所指定的长度。

#java.lang.StringBuffer.setLength()方法的声明
#public void setLength(int newLength)
#参数newLength -- 这是新的长度
#返回值:此方法不返回任何值
#异常:IndexOutOfBoundsException -- 如果newLength参数是负
#实例:使用java.lang.StringBuffer.setLength()方法
package com.yiibai;
import java.lang.*;
public class StringBufferDemo {
public static void main(String[] args) {
    StringBuffer buff = new StringBuffer("tutorials");
    System.out.println("buffer1 = " + buff);  
    // length of stringbuffer
    System.out.println("length = " + buff.length());
         
    // set the length of stringbuffer to 5
    buff.setLength(5);
         
    // print new stringbuffer value after changing length
    System.out.println("buffer2 = " + buff);
    // length of stringbuffer after changing length
    System.out.println("length = " + buff.length());
  }
}
 
#编译和运行上面的程序,这将产生以下结果:
buffer1 = tutorials
length = 9
buffer2 = tutor
length = 5

多线程:

https://www.cnblogs.com/wxd0108/p/5479442.html

利用Gradle的productFlavors使用应用多现场配置

https://blog.youkuaiyun.com/zz6880817/article/details/79449465

 

关于RecyclerView

https://www.jianshu.com/p/aff499a5953c

https://blog.youkuaiyun.com/briblue/article/details/70161917

RecyclerView探索之通过ItemDecoration实现StickyHeader效果

https://blog.youkuaiyun.com/briblue/article/details/70211942

跑马灯


        <TextView
            android:id="@+id/pass_list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="@dimen/general_title_margin_top"
            android:background="#22193459"
            android:ellipsize="marquee"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:marqueeRepeatLimit="marquee_forever"
            android:paddingLeft="@dimen/general_list_margin"
            android:paddingRight="@dimen/general_list_margin"
            android:scrollHorizontally="true"
            android:singleLine="true"
            android:textColor="#FF9C56"
            android:textSize="@dimen/general_list_item_callinfo_text_size" />

实战篇ConstraintLayout的崛起之路

https://www.jianshu.com/p/a74557359882

安卓编译错误app:compileDebugJavaWithJavac>Compilation failed; see the compiler error output for details.

https://blog.youkuaiyun.com/Daxue_haha/article/details/78605047

android开发规范文档

https://blog.youkuaiyun.com/wangkuan219/article/details/52576762

浮点数的二进制表示

http://www.ruanyifeng.com/blog/2010/06/ieee_floating-point_representation.html

http://www.cnblogs.com/n-u-l-l/archive/2012/05/12/2497063.html

https://blog.youkuaiyun.com/u011362822/article/details/30245967

Java之道系列:BigDecimal如何解决浮点数精度问题

https://yq.aliyun.com/articles/20309

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值