This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi folks, Pls suggest a good way of doing the below requirement. I have a collection of userprofile objects (around 500..not in order). I need to display these on a jsp(easy part)..which has filter keys like a-h,I-P,Q-z like filters on the page. On click of any of the links I need to display the user names starting with I thro P in asc order. I am thinking of using comparator for this. compare(obj1,obj2) Profile p1 = (Profile)obj1; Profile p2 = (Profile)obj1; then take the substring of user name's first char from p1 and p2 then if c1 > 'A' and c1 < 'H' return 1 else if c1 < 'A' and c1 > 'H' return -1 else if equal return 0
Is this a good way of doing this..Please suggest. Thanks
I would either : 1. Go through all user and extract those whose name begins with I-P 2. Sort the new list Or 1. Manage all users in a sortable list (e.g. a SortedSet) 2. Extract users whose name begins with I-P
The compare() should return something like : return p1.getName().compareTo(p2.getName())