In HashSet duplicates are allowed while adding to the HashSet,
but while retreiving the object from HashSet is not shown the
duplicate values, WHY ?
Answers were Sorted based on User's Feedback
Answer / brijendra kumar (xavient)
Actually in HashSet we are able to add the duplicate value,
but at the execution time JVM ignore the duplicate value.
HashSet<String> T= new HashSet<String>();
T.add("k");
T.add("k");
System.out.println("size" +T.size());
when we execute these line of code then we got the size of
HashSet is 1.
Due to this reason we are unable to iterate the duplicate
value from HashSet.
Is This Answer Correct ? | 7 Yes | 2 No |
Answer / shashi
Because HashSet class will override equals and hashcode method internally.
Is This Answer Correct ? | 0 Yes | 0 No |
Write a postfix expression to (a*(b+c/d)*d-e)
How to call the m1() method of Base class in below snippet ? class Base { public void m1() { System.out.println("Base m1 "); } public void m2() { System.out.println("Base m1 "); } } ====================== class Derived extends Base { public void m1() { System.out.println("Derived m1"); } public void m3() { System.out.println("Derived m3"); } public static void main(String[] args) { Base ob=new Derived(); ob.m1(); //System.out.println("Hello World!"+ob.m1()); } }
what is the IDE that you have used to write your java programs?
2 Answers Inforica, Interface Software,
What is the use of hashcode in java ?
what is mean by hasing and maping in java platform and advantage?
HOW MUCH PERCENTAGE WE DEDUCT FOR OUR SUPPLIERS OR OTHER PROFESSIONALS
i need java 1+ experience resume on java developer kindly send me my mail id:srikanthreddy1.marla@gmail.com
What are the uses of the set interfaces in the java collections? : java collections
What is need of DAO? Write one simple DAO example?
What are the different types of classes implemented in the set interfaces? : java collections
In hyderabad, which s/w training center is best for java, other than corejava what r the new tools to learn in java,which tool is best & have current requirement,pls give me information about java to learn ?
How do you debug your java program?