how to print out this new data structure by constructing a new method printList which displays the contents of a LinkedList aList. using (print) as a template.
public void actionPerformed(ActionEvent event) {
String[] anArray=null;
if (event.getSource() == reading) {
String s = txt1.getText();
String delims = expression.getText();
anArray = s.split(delims);
result.setText("");
print(anArray);
}
LinkedList<String> mkList;
java.util.List<String> aList = new LinkedList<String>();
} // actionPerformed
public LinkedList<String> mkList(String[] sa) {
LinkedList<String> st = new LinkedList<String>();
for (int i = 0; i < sa.length && sa[i] != null; i++)
st.add(sa[i] + "\n");
return st;
} // mkList
public void print(String[] sa) {
for (int i = 0; i < sa.length && sa[i] != null; i++)
result.append(sa[i] + "\n");
// Log the results to the terminal
System.out.println("Input: '" + txt1.getText() + "'");
System.out.println("Regular Expression: '" + expression.getText() +"'");
System.out.println("Output:\n" + result.getText());
} // print