Originally posted by Kaydell Leavitt:
[QB]Here is a link from the Sun tutorials:
Sun Tutorial On The Collections Framework
I can't say that I understand it perfectly either, but I would concentrate first on the interfaces and then on the concrete classes that implement the interfaces.
If you don't understand some of it such as what a HashMap and what a LinkedList is, you should study the data structures and algorithms.
Kaydell
QB]
Thanks for your reply Kaydell! I have actually done that I know the stucture - Collections, Lists, Sets, Maps, SortedMap etc.
I also know which classes implement or extend which interface or class respectively.
I can define a List, Set, Map.
But,, given a problem, I dont know how to browse and find the appropriate method in the Collection API.
For example:
Lets say I have a
String like : "Hello Javaranch heLLo JavaRanch".
I would like to do 2 things
Reverse the words : "JavaRanch heLLo Javaranch Hello"&, I would like to delete duplicates - so the output is "Javaranch Hello" Please note that the string could be of any length and the method that matches the words has to be case
insensitive(i.e heLLO = Hello) and the output should be sentence case like "Javaranch Hello"
My approach would be to parse the line get the tokens into a String array, convert everything into a small case then put them into a set. and display them in reverse order.
My question is not necessarily about the solution to above example. How do I find out that the approach I employ is the best one? How do I find out if there is a method in the Collections API which makes my life easier?
Thanks
Vivek