In most of the interviews, im facing this question, but if i explain the Concept of Set, Array, List. Almost everytime, Interviewer is not satisfied,and they are concentrating on how to know "Which one to Use When"?
Use an Array only when you know the size of the collection will never change, and when the ease of access by array index trumps every other consideration. Almost everything you need to do is easier when working with a List or a Set.
Use a Set when you want to be sure that the collection will contain no duplicate elements.
Use a List if your collection needs to accommodate the possibility that elements appear more than once. The List should be your go-to data structure; use it unless you have a good reason to use something else.
Mallik kannan wrote:but if i explain the Concept of Set, Array, List. Almost everytime, Interviewer is not satisfied...
Probably because you don't know what they are yourself; and the only way to find out is (as others have said) to read either (a) the tutorials, (b) the API documentation, or (c) (if you can afford it) a good book.
Personally, I'd go with (b) because not only do they tell you what they are meant to do (look at the interface docs), but also precisely how they are implemented for Java. Some people find them too dry though, so I can quite understand why you might want to go with a tutorial.
I'm surprised that nobody's mentioned Maps...
Isn't it funny how there's always time and money enough to do it WRONG?