Vass Lee wrote:As per data (table format) i want to sort the data in Column level
List<HashMap> is type of collection is help to me?
You'd be much better off creating a class to hold that data (Person?) and then just creating a List<Person>. If you make your Person class Comparable, you can just sort it as is; otherwise one of the Collections.sort() methods also takes a Comparator.
Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here
Joined: Nov 16, 2011
Thanks for your reply. Can you provide any sample for Creating Person class and how to hold the data in that class.?
@Vass: the only slight change I'd make to Nomaan's suggestion is not to use Strings for everything. 'Age' is plainly a numeric value, so make it one, viz:and I suspect you'll also discover that something like "skill" is actually a code that is stored elsewhere in your database. If it is, then make it a class (or an enum) too. If not, forget what I said and just use a String.
Joined: Nov 16, 2011
Thanks for your reply.Now i want to apply some filters in column level .how can i apply filter in person class? any filter method is there in java.util. package? can you provide any sample here ?
Vass Lee wrote:Thanks for your reply.Now i want to apply some filters in column level .how can i apply filter in person class? any filter method is there in java.util. package? can you provide any sample here ?
Just a small point: you're in Java now and you have a class, so it's best not to think in terms of "columns" any more. Databases have columns, Java has fields (or attributes). Assuming that, per Nomaan's example, you have a java.util.List of Persons, a filtering method might look something like this:however, filters and sorts being what they are, there are endless possibilities (and you might even want to combine the two), so as the others say you should probably look at java.lang.Comparable and java.util.Comparator as well.
Also, Java has a dizzying array of collection types, some of which are very powerful, so I suggest you have a look at the tutorials and get familiar with them.