I am having a problem. I have the string src below to be split based on the specified delimiters in an ArrayList. Each section split has to go in an array for further splitting to words. However my problem is that the ! after all is not cater, while the ? is. I encounter that problem if any 2 different delimiters in the list are present in the String src. Can you tell me what is wrong with my code or tell me an easier way to perform the sentence splitting. Thank you for your time.
public class temp
{
    public static void main(String[] args)
    { 
        boolean flag = false;
        int j;
        String word;
        ArrayList <String> delimiter = new ArrayList <String>();
        delimiter.add("!");
        delimiter.add(".");
        delimiter.add("?");
        String src = "Hello all! today is a great day?";
        String parts[] = new String[src.length()];
        String mot[] = new String[src.length()];
        String temp;
        for(int i=0;i<src.length();i++)
        {
            j=0;
            if(src.charAt(i) == delimiter.get(j).charAt(0))
            {
                System.out.println("first");
                parts = src.split("!");
                parts.toString();
        }
            j++;
            if(src.charAt(i) == delimiter.get(j).charAt(0))
            {
                System.out.println("second");
                parts = src.split("\\.");
                parts.toString();
            }
            j++;
            if(src.charAt(i) == delimiter.get(j).charAt(0))
            {
                System.out.println("third");
                parts = src.split("\\?");
                parts.toString();
            }
        }
        System.out.println(Arrays.toString(parts));
        for(int i=0;i<parts.length;i++)
        {
            word = parts[i];
            mot = word.toLowerCase().split(" ");
        }
        System.out.println(Arrays.toString(mot));
    }
}
my output is as follows : first
third [Hello all! today is a great day] [hello, all!, today, is, a, great, day]
 
     
    