java:jfc_intf_sorted_set_map
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| java:jfc_intf_sorted_set_map [2017/03/28 23:48] – [java.util.SortedSet] gthanos | java:jfc_intf_sorted_set_map [2020/03/15 18:48] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 10: | Line 10: | ||
| * **[[http:// | * **[[http:// | ||
| - | <code java NameSortedSet.java> | + | <code java StudentSortedSet.java> |
| import java.util.*; | import java.util.*; | ||
| - | public class NameSortedSet | + | public class StudentSortedSet |
| - | static final Comparator< | + | |
| - | new Comparator< | + | |
| - | public int compare(Name n1, Name n2) { | + | |
| - | int cmp = n1.firstName().compareTo(n2.firstName() ); | + | |
| - | return (cmp != 0 ? cmp : n1.lastName().compareTo(n2.lastName() )); | + | |
| - | } | + | |
| - | }; | + | |
| public static void main(String[] args) { | public static void main(String[] args) { | ||
| | | ||
| - | SortedSet< | + | SortedSet< |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | students.add(new Student(" |
| - | for(Name n: names) | + | |
| + | for(Student | ||
| System.out.println(n); | System.out.println(n); | ||
| | | ||
| System.out.println(" | System.out.println(" | ||
| | | ||
| - | SortedSet< | + | SortedSet< |
| - | for(Name n: subnames) | + | for(Student s: subStudents) |
| - | System.out.println(n); | + | System.out.println(s); |
| | | ||
| System.out.println(" | System.out.println(" | ||
| | | ||
| - | | + | |
| - | for(Name n: subnames) | + | for(Student s: subStudents) |
| - | System.out.println(n); | + | System.out.println(s); |
| } | } | ||
| } | } | ||
java/jfc_intf_sorted_set_map.1490744884.txt.gz · Last modified: 2017/03/28 22:48 (external edit)
