Question
Question 1: Write a program that reads words into two ArrayLists list1 and list2 and then creates a third ArrayList that contains words which are
Question 1: Write a program that reads words into two ArrayLists list1 and list2 and then creates a third ArrayList that contains words which are common to both list1 and list2. You may assume that the strings are entered as words separated by a space on a single line and the end is signaled by -1 (String -1). You can use keyboard.next() to read each word.
Question 2: Write a program that reads words into an ArrayList list1 and creates another ArrayList list2 that has the same words in list1 but no duplicates.
*I am using JGrasp so please make sure it is compatible *Please comment throughout code *FULL QUESTION IN IMAGES BELOW
Exercise 1: Write a program that reads words into two ArrayLists list 1 and list2 and then creates a third Array List that contains words which are common to both list1 and list2. You may assume that the strings are entered as words separated by a space on a single line and the end is signaled by "-1" (String -1). You can use keyboard.next0 to read each word. A sample dialog is shown below Enter words on one line, end with -1 java c pascal ada java c++ -1 Enter words on one line, end with -1 c pascal java lisp isp -1 java c, pascal ada java, C++] CC, pascal java, lisp, lisp Array List with common strings: [c, pascal java Exercise 2: Write a program that reads words into an ArrayList list1 and creates another ArrayList list2 that has the same words in list1 but no duplicates. A sample dialog is shown below: Enter words on one line, end with -1 java c pascal ada java java ada C++ -1 Array List with no duplicates java C, pascal ada c++]Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started