java 7 comparator,condition Check

package list;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class MyClass {

public static void main(String[] args) {

List people = Arrays.asList(new Person(“Remzi”, “Altan”, 23), new Person(“Ali”, “Tuzen”, 23),
new Person(“Funda”, “Tekin”, 24), new Person(“Ceyda”, “Ozbay”, 25));

Collections.sort(people, new Comparator() {

@Override
public int compare(Person ob1, Person ob2) {

return ob1.getName().compareTo(ob2.getName());
}

});

printCond(people, new Condition() {

@Override
public boolean match(Person p) {

return p.getLastname().startsWith(“T”);
}
});

}

private static void printCond(List people, Condition condition) {
for (Person p : people) {
if (condition.match(p)) {
System.out.println(p.getName() + ” ” + p.getLastname() + ” ” + p.getAge());
}

}

}

}

interface Condition {
boolean match(Person p);
}

Advertisements

  1. #1 by Alex on January 20, 2018 - 10:16 pm

    I am no longer sure where you’re getting your info, however good topic. I must spend some time finding out much more or working out more. Thank you for wonderful information I used to be searching for this information for my mission.

  2. #2 by Alex on January 20, 2018 - 10:57 pm

    Wow, awesome weblog structure! How long have you ever been blogging for? you make blogging glance easy. The entire glance of your web site is magnificent, as well as the content material!

  3. #3 by Alex on January 21, 2018 - 11:55 am

    Wow, fantastic weblog structure! How lengthy have you ever been blogging for? you made blogging glance easy. The entire glance of your site is magnificent, as smartly as the content!

  4. #4 by sezayir on January 22, 2018 - 10:46 am

    this is not a blog and do not expect public benefit:) it take just a note

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: