Skip to main content
don't use linked hash
Source Link
ratchet freak
  • 48.4k
  • 5
  • 76
  • 114

here I'm using a hashset to store seen lines

Scanner scan;//input Set<String> lines = new LinkedHashSet<String>HashSet<String>(); StringBuilder strb = new StringBuilder(); while(scan.hasNextLine()){ String line = scan.nextLine(); if(lines.add(line)) strb.append(line); } 

here I'm using a hashset to store seen lines

Scanner scan;//input Set<String> lines = new LinkedHashSet<String>(); StringBuilder strb = new StringBuilder(); while(scan.hasNextLine()){ String line = scan.nextLine(); if(lines.add(line)) strb.append(line); } 

here I'm using a hashset to store seen lines

Scanner scan;//input Set<String> lines = new HashSet<String>(); StringBuilder strb = new StringBuilder(); while(scan.hasNextLine()){ String line = scan.nextLine(); if(lines.add(line)) strb.append(line); } 
deleted 55 characters in body
Source Link
MatBanik
  • 26.9k
  • 40
  • 119
  • 179

here I'm using a hashset to store seen lines

Scanner scan;//input Set<String> lines = new HashSet<String>LinkedHashSet<String>(); StringBuilder strb = new StringBuilder(); while(scan.hasNextLine()){ String line = scan.nextLine(); if(!lines.contains(line)){ lines.add(line); ) strb.append(line); } } 

here I'm using a hashset to store seen lines

Scanner scan;//input Set<String> lines = new HashSet<String>(); StringBuilder strb = new StringBuilder(); while(scan.hasNextLine()){ String line = scan.nextLine(); if(!lines.contains(line)){ lines.add(line);  strb.append(line); } } 

here I'm using a hashset to store seen lines

Scanner scan;//input Set<String> lines = new LinkedHashSet<String>(); StringBuilder strb = new StringBuilder(); while(scan.hasNextLine()){ String line = scan.nextLine(); if(lines.add(line)) strb.append(line); } 
Source Link
ratchet freak
  • 48.4k
  • 5
  • 76
  • 114

here I'm using a hashset to store seen lines

Scanner scan;//input Set<String> lines = new HashSet<String>(); StringBuilder strb = new StringBuilder(); while(scan.hasNextLine()){ String line = scan.nextLine(); if(!lines.contains(line)){ lines.add(line); strb.append(line); } }