repeat every wordcount repeat of every word : I want to write a code that count repeat of every word in a string,words separate each other with some character that input as a string...why my code don't work?
please answer soon! 
import java.util.Scanner;

public class repeat {

    public static void main(String[] args) {
        Scanner ss = new Scanner(System.in);
        System.out.println("Please write a string:");
        String s = ss.nextLine();
        System.out.println("Please write a character:");
        String w = ss.nextLine();
        int i = 0;
        int j = 0;
        int k = 0;
        int y=0;
        for (i=0 ;i < s.length() ;i++) {
            for (j = 0; j < w.length(); j++) {
                if (w.charAt(j) == s.charAt(i) && i!=y && i!=0 && i!=s.length() -1 ) {
                    k += 1;
                    y=i+1;
                }
            }
        }
        i = 0;
        j = 0;
        y = 0;
        int r = 0;
        k++;
        System.out.println(k);
       String[] a = new String[k];
        for (r=0 ;r < k-1 ;r++) {
            for (j=1 ;j < s.length() ;j++) {
                for (i = 1; i < w.length(); i++) {
                    if (w.charAt(i) == s.charAt(j)) {
                        a[r] = s.substring(y, j);
                        y = j+1;
                    }
                }
            }
            System.out.println(a[r]);
        }
        a[k-1] = s.substring(y+1,s.length());
        i = 0;
        int[] b = new int[k];
        while (i <k) {
            b[i] = 0;
            i++;
        }
        i = j = 0;
        while (i < k) {
            while (j != i && j < k) {
                if (a[i] == a[j]) {
                    a[j] = null;
                    b[i]++;
                }
                j++;
            }
            i++;
        }
        i = j = 0;
        while (i < k) {
            if (a[i] != null) {
                System.out.println(a[i] + " " + b[i]);
            }
            i++;
        }
    }
}
