Please answer the question posted and give full explanation of the answer. Please past the successful program run as well. Create a Java project with the following code. Please remember to type in this code rather than copy-and-pasting; Word loves to mangle source code. import java.util.*; import java.io.*; public class ArrayListTest {           public static void main(String[] args)  {                               String myString = "To be, or not to be,\r\n" +                                  "that is the question. Whether 'tis\r\n" +                                  "nobler in the mind to suffer\r\n" +                                "the slings and arrows of outrageous fortune,\r\n" +                                  "Or to take Arms against a Sea of Troubles\r\n" +                                  "And by opposing end them.\r\n";                               // build the list of stop words                ArrayList stopWords = new ArrayList();                stopWords.add("a");                stopWords.add("be");                stopWords.add("by");                stopWords.add("how");                stopWords.add("in");                stopWords.add("is");                stopWords.add("it");                stopWords.add("of");                stopWords.add("on");                 stopWords.add("or");                stopWords.add("that");                stopWords.add("the");                stopWords.add("this");                stopWords.add("to");                stopWords.add("why");                  // process the file, printing all but stop words                  Scanner input = new Scanner(myString);                while (input.hasNext()) {                        String next = input.next();                        if (!stopWords.contains(next.toLowerCase())) {                                System.out.print(next + " ");                        }                  }         } } Once the program works as expected, answer the following questions:  2.1. The ArrayList is declared using ArrayList. What does mean in this context?                  a. The ArrayList is stored inside a single String String is the template type for the ArrayList The ArrayList is cast to String for purposes of .ToString 2.2. Can you add items to an ArrayList after it has been declared? Yes / No 2.3. What method do we use to add items to an ArrayList? 2.4. Which method is used in the if statement to check if a word should or should not be printed? 2.5.  What is the meaning of the exclamation point (!) in the Boolean expression of the if condition?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please answer the question posted and give full explanation of the answer. Please past the successful program run as well.

Create a Java project with the following code. Please remember to type in this code rather than copy-and-pasting; Word loves to mangle source code.

import java.util.*;

import java.io.*;

public class ArrayListTest {

 

        public static void main(String[] args)  {

              

               String myString = "To be, or not to be,\r\n" +

                                 "that is the question. Whether 'tis\r\n" +

                                 "nobler in the mind to suffer\r\n" +

                               "the slings and arrows of outrageous fortune,\r\n" +

                                 "Or to take Arms against a Sea of Troubles\r\n" +

                                 "And by opposing end them.\r\n";

              

               // build the list of stop words

               ArrayList<String> stopWords = new ArrayList<String>();

               stopWords.add("a");

               stopWords.add("be");

               stopWords.add("by");

               stopWords.add("how");

               stopWords.add("in");

               stopWords.add("is");

               stopWords.add("it");

               stopWords.add("of");

               stopWords.add("on");

                stopWords.add("or");

               stopWords.add("that");

               stopWords.add("the");

               stopWords.add("this");

               stopWords.add("to");

               stopWords.add("why");

 

               // process the file, printing all but stop words

 

               Scanner input = new Scanner(myString);

               while (input.hasNext()) {

                       String next = input.next();

                       if (!stopWords.contains(next.toLowerCase())) {

                               System.out.print(next + " ");

                       }

 

               }

        }

}

Once the program works as expected, answer the following questions: 

2.1. The ArrayList is declared using ArrayList<String>. What does <String> mean in this context?
                 a. The ArrayList is stored inside a single String

  1. String is the template type for the ArrayList
  2. The ArrayList is cast to String for purposes of .ToString

2.2. Can you add items to an ArrayList after it has been declared? Yes / No

2.3. What method do we use to add items to an ArrayList?

2.4. Which method is used in the if statement to check if a word should or should not be printed?

2.5.  What is the meaning of the exclamation point (!) in the Boolean expression of the if condition?

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Top down approach design
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education