public class StringBufferDemo1 {
public static void main(String[] args) {
//字符串的倒序输出
System.out.println("请输入一个字符串");
String s =sc.nextLine();
char arr[]=s.toCharArray();
String ss="";
for (int i = arr.length-1; i >=0; i--) {
ss=ss+arr[i];
}
System.out.println(ss);
String max = "heima,asd,fgh,jkl,zxc,vfr,wddg,ssfh,ad,heima";
String min = "heima";
int count = 0;
int index = 0;
while ((index = max.indexOf(min)) != -1) {
count++;
max = max.substring(index, min.length());
}
System.out.println(count);
// 数组的遍历
String s="dffhjsdsds";
for (int i = 0; i < s.length(); i++) {
System.out.println(s.charAt(i));//获取每个字符串的字符
}
}
} |
|