Question
Stuck at one part of finding duplicates in a java program. ~Line 95 within my getOverLap(), I'm stuck with combing through. I know I need
Stuck at one part of finding duplicates in a java program. ~Line 95 within my getOverLap(), I'm stuck with combing through. I know I need to do a nested j++ within the i but I'm stuck. I know this is an arcaic way of solving this but we're confined to the material we've only covered so far. Not sure how to attach the word.txt file here but my code is below.
Thanks for any advice!
*********************************
Program requirements:
Write a program to:
1) input values from a file called words.txt. The file consists of multiple records of multiple words.
2) read all of the words into one ArrayList
3) interrogate the ArrayList and remove all duplicate words.
4) display the ArrayList with all duplicate words removed.
*********************************
1 /******************************* 2 * Author: Danielle Coulter 3 * Title: a2_scan_for_duplicates.java 4 * Description: ArrayLists and duplicates 5 * Material: Chapter 10 6 * Date: 10/15/2017 7 * 8 * 9 * This program is designed to accept input from one .txt file, 10 * arrange the words into an array, and then scan for duplicates. 11 * 12 * Duplicates will be removed and then displayed on the console. 13 * 14 * @author Danielle Coulter 15 ****************************** 16 */ 17 18 import java.util.ArrayList; 19 import java.util.Collections; 20 import java.util.Scanner; 21 import java.io.FileNotFoundException; 22 import java.io.File; 23 24 public class a2_scan_for_duplicates{ 25 26 public static void main(String []args) 27 throws FileNotFoundException { 28 29 //hard-coded filename 30 //Scanner in1 = new Scanner(new File("words.txt")); 31 Scanner console = new Scanner(System.in); 32 33 //Prompt user for file name 34 System.out.println("Let's clean this up!"); 35 System.out.println("What's your file name? "); 36 Scanner in1 = new Scanner(new File(console.nextLine())); 37 System.out.println(); 38 39 //Scan words in file and store in a list 40 ArrayList
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