Stirng字符串基本函数
发布日期:2021-05-04 09:31:37 浏览次数:33 分类:精选文章

本文共 1005 字,大约阅读时间需要 3 分钟。

package com;public class stringTest1 {       public static void main(String[] args) {       String str=new String();    byte[] b={   1,2,3,4};        String s = new String( b );        System.out.println( s );        System.out.println( "hello".length() );        char[] c={   '1','b'};//      字符数组转化为字符串        String s1 = new String( c );        System.out.println( s1 );//        只可以去掉前面的空格,不可以去掉后面的        System.out.println( "  hou zhi cong".trim() );//           比较第一个字母相减        System.out.println( "abc".compareTo( "a" ) );//        布尔方法 返回true 或者false        System.out.println( "abc".equalsIgnoreCase( "ABc" ) );//        u返回下标是2的字符        System.out.println( "houzhicong".charAt( 2 ) );//        [1,3)ou        System.out.println( "houzhicong".substring( 1, 3 ) );//        判断前缀是不是123是 true        System.out.println( "123456".startsWith( "123" ) );        System.out.println( "houzhicong".endsWith( "g" ) );//从3开始找,看是否有符合条件的数字        System.out.println( "houzhicong".indexOf( "c", 3 ) );    }}
上一篇:VMware15的安装,CentOs,SecureCRs(便于多台机器连接的操作)(安装)
下一篇:打印空心的金字塔

发表评论

最新留言

不错!
[***.144.177.141]2025年03月20日 22时51分41秒