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 ) );
}
}
Stirng字符串基本函数
猜你喜欢
转载自blog.csdn.net/houzhicongone/article/details/114297311
今日推荐
周排行