package com.string;
public class StringTest {
public static void main(String[] args){
String a= "abcd";
//得到数组中的值
char c =a.charAt(1);
System.out.println(c);
////
// String a = "abc";
// String b ="abc";
// //比较两个字符串是否相等 不区分大小写
// System.out.println(a.equalsIgnoreCase(b));
// //得到指定字符串,第一次出现自c字符串的下表,如果c中不包含该字符串返回-1
// String c ="abcdebcd";
// int index = c.indexOf("bc");
// //得到指定字符串,最后一次出现在c字符串
// int last =c.lastIndexOf("bc");
// System.out.println(index+""+last);
// //得到字符串的长度
// int len =c.length();
// System.out.println(len);
String d = "abcbcdefad";
//将指定的字符串替换为新字符串
d = d.replace("ab", "");
System.out.println(d);
String e ="abcefg";
//从下标为2开始,截取字符串
e = e .substring(2);
System.out.println(e);
String f ="abcdefg";
//从下标为1开始,4结束,截取字符串,包含1不包含4
f = f.substring(1,4);
System.out.println(f);
String g =" a b c d e f";
//去掉前后的空格
g=g.trim();
System.out.println(a+"*");
}
}
public class StringTest {
public static void main(String[] args){
String a= "abcd";
//得到数组中的值
char c =a.charAt(1);
System.out.println(c);
////
// String a = "abc";
// String b ="abc";
// //比较两个字符串是否相等 不区分大小写
// System.out.println(a.equalsIgnoreCase(b));
// //得到指定字符串,第一次出现自c字符串的下表,如果c中不包含该字符串返回-1
// String c ="abcdebcd";
// int index = c.indexOf("bc");
// //得到指定字符串,最后一次出现在c字符串
// int last =c.lastIndexOf("bc");
// System.out.println(index+""+last);
// //得到字符串的长度
// int len =c.length();
// System.out.println(len);
String d = "abcbcdefad";
//将指定的字符串替换为新字符串
d = d.replace("ab", "");
System.out.println(d);
String e ="abcefg";
//从下标为2开始,截取字符串
e = e .substring(2);
System.out.println(e);
String f ="abcdefg";
//从下标为1开始,4结束,截取字符串,包含1不包含4
f = f.substring(1,4);
System.out.println(f);
String g =" a b c d e f";
//去掉前后的空格
g=g.trim();
System.out.println(a+"*");
}
}