Automation Using Selenium Webdriver

Thursday, 6 April 2017

how-to-find-duplicate-words-in-string


======How To Find Duplicate Words In String==========


public class DuplicateWordsInString
{
public static void main(String[] args)
{
String test = "This sentence contains two words, one and two";
Set<String> duplicates = duplicateWords(test);
System.out.println("input : " + test);
System.out.println("output : " + duplicates);
 }
/** * Method to find duplicate words in a Sentence or String * @param input String * @return set of duplicate words */
 public static Set<String> duplicateWords(String input)
{
 if(input == null || input.isEmpty()){
return Collections.emptySet();
 }
 Set<String> duplicates = new HashSet<>();
 String[] words = input.split("\\s+");
 Set<String> set = new HashSet<>();
 for(String word : words){ if(!set.add(word))
{
duplicates.add(word);

}
 }
 return duplicates;
}
 }
Output : input : This sentence contains two words, one and two
output : [two]

how-to-find-duplicate-words-in-string

6 comments:


  1. Amazing, thanks a lot my friend, I was also siting like a your banner image when I was thrown into Selenium.When I started learning then I understood it has got really cool stuff.
    I can vouch webdriver has proved the best feature in Selenium framework.
    Thanks a lot for taking a time to share a wonderful article.


    Selenium Training in Velachery

    ReplyDelete

  2. The biggest change in Selenium recently has been the inclusion of the WebDriver API. Driving a browser natively as a user would either locally or on a remote machine using the Selenium Server it marks a leap forward in terms of browser automation.

    Selenium WebDriver fits in the same role as RC did, and has incorporated the original 1.x bindings. It refers to both the language bindings and the implementations of the individual browser controlling code. This is commonly referred to as just "WebDriver" or sometimes as Selenium 2.
    Selenium Training Institute in Chennai

    Get your selenium questions answered by experts - Selenium FAQs

    ReplyDelete
  3. Selenium Webdriver With Java. : How-To-Find-Duplicate-Words-In-String >>>>> Download Now

    >>>>> Download Full

    Selenium Webdriver With Java. : How-To-Find-Duplicate-Words-In-String >>>>> Download LINK

    >>>>> Download Now

    Selenium Webdriver With Java. : How-To-Find-Duplicate-Words-In-String >>>>> Download Full

    >>>>> Download LINK YU

    ReplyDelete