How to find number of spaces, number of words and return actual words for given sentence

Below is the complete solution for the APCS problem where for a given sentence, find number spaces, number of words and also return the words.

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

//solution for problem 2 from BAR7APCS1

public class Sentence {

	private String sentence;

	public Sentence(String sentence) {
		this.sentence = sentence;
	}

        //solution for problem 2(a)
	public List getBlankPositions() {
		List l = new ArrayList();
		for (int i = 0; i < sentence.length(); i++) {
			if (sentence.charAt(i) == ' ') {
				l.add(i);
			}
		}
		return l;
	}
        //solution for problem 2(b)
	public int countWords() {
		return getBlankPositions().size() + 1;
	}

        //solution for problem 2(c)
	public String[] getWords() {
		String[] words = new String[countWords()];
		words = sentence.split(" ");
		return words;
	}
        //Testing the code
	public static void main(String[] args) {
		Sentence s = new Sentence("The cat sat on the mat");
		System.out.println(s.getBlankPositions());
		System.out.println(s.countWords());
		String[] words = s.getWords();
		System.out.println(Arrays.toString(words));
	}

}