package com.net.ch02;
public class Split {
public void func(String str,String s){
String Str = s+str+s;
String[]array = new String[100];
int[]ray = new int[100];
for(int i = 1 ; i<=Str.length();i++ ){
array[i-1] = Str.substring(i-1, i); **
}
int j=0;
** for(int i = 0 ; i <=Str.length()-1;i++){
if (array[i].equals(s)){
ray[j] = i;
j++;
}
}
ray[j]=Str.length();
for(int i =0;i<j;i++){
System.out.print(Str.substring(ray[i]+1, ray[i+1])+"\t");
}
}
public static void main(String[] args) {
String str = "jlkjdsf fjkaf";
String s = " ";
Split sa = new Split();
sa.func(str,s);
}
}
以上是本人的代码,粗体部分感觉越界了,但是还是能编译过去,谢谢