public class Demo03 {
 public static void main(String[] args) {
		// TODO Auto-generated method stub
		char[] ch={‘a‘,‘b‘,‘c‘,‘d‘,‘e‘};
		String str=new String(ch);
		String str1=new String(ch,1,2);
		System.out.println(str);
		System.out.println(str1);
	    //字符串长度
		int len=str.length();
		System.out.println(len);
		//截取字符串
		String s1=str.substring(2);
		//从起始位置街渠道结束位置(包头不包尾)
		String s2=str.substring(2,3);
		System.out.println(s1);
		//判断开头和结尾
		String strr="I Love J";
		String s3="II";
		String s4="J";
		System.out.println(strr.startsWith(s3));
		System.out.println(strr.endsWith(s4));
		//判断字符串是否包含字符串
		String s5="I Love J ,J is the Best";
		String s6="j";
		boolean f1=s5.contains(s6);
		System.out.println(f1);
		//indexof 如果没有改字符串则返回-1
		System.out.println(s5.indexOf(s6));
		//将字符串转成字节/字符数组
		String s7="伟哥";
		byte[] b1=s7.getBytes();
		for(int  i=0; i<b1.length;i++){
			System.out.println(b1[i]+" ");
		}
		char[] c1=s7.toCharArray();
		for(int i=0;i<c1.length;i++){
			System.out.println(c1[i]+" ");
		}
		
		//判断字符串内容是否相同
		String s8="Oracle";
		String s9="Oracle";
		System.out.println(s8.equals(s9));
		//不考虑大小写的方法
		System.out.println(s8.equalsIgnoreCase(s9));
		System.out.println(s8.toString());
		//将字符串转成大小写
		System.out.println(s9.toUpperCase());//转大写
		System.out.println(s9.toLowerCase());//转小写
	}
}
原文:https://www.cnblogs.com/a709898670/p/9382379.html