File tree Expand file tree Collapse file tree 4 files changed +3
-6
lines changed
Java-8/src/genericsAndCollections Expand file tree Collapse file tree 4 files changed +3
-6
lines changed Original file line number Diff line number Diff line change 11
11
*
12
12
*/
13
13
public class UsingComparable implements Comparable <UsingComparable > {
14
-
15
14
private String name ;
16
15
17
16
public UsingComparable (String name ) {
18
- // TODO Auto-generated constructor stub
19
17
this .name = name ;
20
18
}
21
19
@@ -25,7 +23,6 @@ public String toString() {
25
23
26
24
@ Override
27
25
public int compareTo (UsingComparable o ) {
28
- // TODO Auto-generated method stub
29
26
return name .compareTo (o .name ); // call String's compareTo
30
27
}
31
28
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ public class UsingComparable1 implements Comparable<UsingComparable1> {
12
12
private int id ;
13
13
14
14
public int compareTo (UsingComparable1 a ) {
15
- return id - a .id ;
15
+ return this . id - a .id ;
16
16
}
17
17
18
18
public static void main (String [] args ) {
Original file line number Diff line number Diff line change @@ -35,9 +35,9 @@ public String toString() {
35
35
public int compareTo (UsingComparator d ) {
36
36
return name .compareTo (d .name );
37
37
}
38
-
39
38
public static void main (String [] args ) {
40
39
Comparator <UsingComparator > byWeight = new Comparator <UsingComparator >() {
40
+ @ Override
41
41
public int compare (UsingComparator d1 , UsingComparator d2 ) {
42
42
return d1 .getWeight () - d2 .getWeight ();
43
43
}
Original file line number Diff line number Diff line change 16
16
* V put(K key, V value) Adds or replaces key/value pair. Returns previous value or null .
17
17
* V remove(Object key) Removes and returns value mapped to key. Returns null if none.
18
18
* boolean containsKey(Object key) Returns whether key is in map.
19
- * boolean containsValue(Object) Returns value is in map.
19
+ * boolean containsValue(Object) Returns whether value is in map.
20
20
* Set<K> keySet() Returns set of all keys.
21
21
* Collection<V> values() Returns Collection of all values.
22
22
*/
You can’t perform that action at this time.
0 commit comments