If set accepts only one argument then how can it compare
two objects to avoid duplicates
Answer Posted / r.jainrocks@gmail.com
Set compares hash code of new instance which
has to include in set with already containing values in Set.
because of this comparing b/w instances adding in set is slow
in Set and retrieval is fast.
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is a variable and constant?
What is the base class of all classes?
Which access specifier can be used with class ?
What are some examples of variable costs?
Write a function to find out longest palindrome in a given string?
Say you want to store the information about a number of pets in an array. Typical information that you could store for each pet (where relevant) would be • Breed of animal • Animal's name • Its birth date • Its sex • Whether it has been sterilised or not • When it is due for its next inoculation • When it last had its wings clipped For each type of pet (eg. dog, cat or bird) you would typically define a class to hold the relevant data. Note: You do not need to implement these classes. Just answer the following questions. 3.1.1 What would be the advantage of creating a superclass (eg. Pet) and declaring an array of Pet objects over simply using an array of Objects, storing each of the instances of the different pet classes (eg. Dog, Cat or Bird) in it? 3.1.2 Would you define Pet as a class or as an interface? Why? (2) (2)
Why java is said to be pass-by-value ?
Difference between class#getinstance() and new operator ?
Difference between method overloading and overriding.
What is the difference between checked exception and unchecked exception?
What do you understand by casting in java language?
How do I convert a string to an int in java?
What do you mean Abstraction in java?
What is assembly used for?
What is the difference between java applets and applications?