Tim Moores wrote:Do you know what an "import" is in Java? If not, work through the relevant section of Oracle's Java tutorial first. After that: how would you use an import to let the Java compiler know that your code wants to use some class, for example 'Comparator"? If you have worked through the tutorial, you would know this, and be able to change your code accordingly.
That looks like guessing. You can guess 1000000× and some of the guesses will be correct, just from luck. Or you can think about what you are doing, and get it right first time.
John Ken wrote:. . . i tried various combinations . . .
Piet Souris wrote:But since this is a friendly place for everyone, I will answer Johns question, and then asking a question to John.
If you look at the code you have in your opening post, you see that you first create the List, and then do the filtering (and not yet sorting). Now, with my code snippet it is just the same: first create a List<Employee>, and when you have that List, you can invoke my code whenever you want: right after where you created the List, or later, if you need the filtering and sorting.
Now my question to you:
that code snippet of mine had the age of 22 built-in, just like that the sorting should take place on the basis of the name. That is not very flexible, to say the least. Now, can you implement this method:
And if you have that implemented, can you give an example of how to use this method?
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton