package Homework;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
/**
* 把数组中的数据按照指定个格式拼接成一个字符串
举例:int[] arr = {1,2,3}; 输出结果:[1, 2, 3]
字符串反转
举例:键盘录入”abc” 输出结果:”cba”
统计大串中小串出现的次数
举例:在字符串” woaijavawozhenaijavawozhendeaijavawozhendehenaijavaxinbuxinwoaijavagun”
中java出现了5次
* @author 张致远
*
*/
public class Homework3 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
String a1=new String("1,2,3");
char[] char1=a1.toCharArray();
for(int i=0;i<char1.length;i++){
System.out.print(char1[i]);
// System.out.println("char1"+"["+i+"]="+char1[i]+" ");
}
//// -----------------------------------(2)----------------------------------------
System.out.print("请输入:");
String a2=in.nextLine();
char[] char2=a2.toCharArray();
for(int i=char2.length-1;i>=0;i--){
System.out.print(char2[i]);
}
//---------------------------------------(3)----------------------------------------
String Big=in.next();
String Small=in.next();
char[] B=Big.toCharArray();
char[] S=Small.toCharArray();
// char[] char3=a3.toCharArray();
int cnt=0;
for(int i=0;i<B.length;i++){
if(B[i]==S[0]){
int juge=0;
for(int j=0;j<S.length;j++){
if(B[i+j]==S[j]){
juge++;
}
else break;
}
if(juge==S.length){
cnt++;
}
}
}
System.out.println("出现次数为"+cnt);
}
}