package com.wh.interview;
import java.util.ArrayList;
import java.util.List;
public class SplitString {
public static void main(String[] args) {
String a="12345654622312582238";
String b="3";
String[] split = split(a, b);
for (String str:split) {
System.out.println(str+" ");
}
}
public static String[] split(String array,String target){
List<String> list=new ArrayList<>();
while (array.contains(target)){
int index = array.indexOf(target);
String temp = array.substring(0, index);
list.add(temp);
array=array.substring(index+target.length());
}
list.add(array);
String arr[]=new String[list.size()];
for (int i = 0; i < list.size(); i++) {
arr[i]=list.get(i);
}
return arr;
}
}