Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Andrew Lohr
- //Assignment 9
- //March 22
- import javax.swing.JOptionPane;
- public class Semester2Assignment9
- {
- public static void main (String args[])
- {
- LinkedList myList;
- myList = new LinkedList();
- String character;
- Character response,data;
- character = JOptionPane.showInputDialog("Enter a character");
- response = character.charAt(0);
- data = new Character (response);
- while (response != '.' )
- {
- myList.add(1,response);
- myList.add(myList.size()+1,response);
- character = JOptionPane.showInputDialog("Enter another character");
- response = character.charAt(0);
- data = new Character (response);
- }
- System.out.println("The size of the list is: " + myList.size());
- System.out.println("The contents of the list are: ");
- for(int i = 1; i <=myList.size(); i++)
- {
- System.out.print(myList.get(i)+ " " );
- }
- }
- }
- Welcome to DrJava. Working directory is C:\Users\Andrew
- > run Semester2Assignment9
- The size of the list is: 16
- The contents of the list are:
- H g F e D c B a a B c D e F g H >
- Welcome to DrJava. Working directory is C:\Users\Andrew
- > run Semester2Assignment9
- The size of the list is: 20
- The contents of the list are:
- K @ * 8 % b [ & W s s W & [ b % 8 * @ K >
Add Comment
Please, Sign In to add comment