CS112: In-class Exercise 16 ArrayList – an improved spell checker. 1. Review of the new ArrayList object . • Required import: import java.util.*; • Declaration: ArrayList< type > variableName; • Instantiation: variableName = new ArrayList< type >(); • Adding new elements to end of array: variableName.add( element ); • Getting the elements corresponding to a certain index . This returns something of corresponding type . variableName.get( index ); • Remember that the indexing starts at 0. • Getting the length (number of elements). This returns an integer. variableName.size(); • Note that the size is one bigger than the last available index. 2. Create a new project InClass16-spellchecker2 . 3. Copy the file dictionary.txt from the usual locations. We are going to use this file of words as a database to check whether a word is spelled correctly. The assumption is that a word is spelled correctly if and only if it is on this list. 4.
This is the end of the preview. Sign up
access the rest of the document.