Posts

Showing posts from May, 2016

How to Find Duplicate String in Java

Since we all known HashSet is a part of Collection that will store unique value always  >  if we are trying to add any duplicate value add method return  false. > add Method check existing Object Hashcode and compare with  newly added Object if hashCode match then add method Return False else Return True . >here we created HashSet<String> Object with generic type data type >since we Added <String> After HashSet then it only allows to add String value >generic type is only use to overcome data type casting problem  .. Please Check below programmer  /*  * To change this license header, choose License Headers in Project Properties.  * To change this template file, choose Tools | Templates  * and open the template in the editor.  */ package javainterview; import java.util.*; /**  *  * @author shiboo  */ public class Duplicate {        ...