Skip to content

Commit 11fce0c

Browse files
author
turingfly
committed
Generics and Collections
1 parent e0b2af6 commit 11fce0c

File tree

4 files changed

+3
-6
lines changed

4 files changed

+3
-6
lines changed

Java-8/src/genericsAndCollections/UsingComparable.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111
*
1212
*/
1313
public class UsingComparable implements Comparable<UsingComparable> {
14-
1514
private String name;
1615

1716
public UsingComparable(String name) {
18-
// TODO Auto-generated constructor stub
1917
this.name = name;
2018
}
2119

@@ -25,7 +23,6 @@ public String toString() {
2523

2624
@Override
2725
public int compareTo(UsingComparable o) {
28-
// TODO Auto-generated method stub
2926
return name.compareTo(o.name); // call String's compareTo
3027
}
3128

Java-8/src/genericsAndCollections/UsingComparable1.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class UsingComparable1 implements Comparable<UsingComparable1> {
1212
private int id;
1313

1414
public int compareTo(UsingComparable1 a) {
15-
return id - a.id;
15+
return this.id - a.id;
1616
}
1717

1818
public static void main(String[] args) {

Java-8/src/genericsAndCollections/UsingComparator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public String toString() {
3535
public int compareTo(UsingComparator d) {
3636
return name.compareTo(d.name);
3737
}
38-
3938
public static void main(String[] args) {
4039
Comparator<UsingComparator> byWeight = new Comparator<UsingComparator>() {
40+
@Override
4141
public int compare(UsingComparator d1, UsingComparator d2) {
4242
return d1.getWeight() - d2.getWeight();
4343
}

Java-8/src/genericsAndCollections/UsingMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* V put(K key, V value) Adds or replaces key/value pair. Returns previous value or null .
1717
* V remove(Object key) Removes and returns value mapped to key. Returns null if none.
1818
* 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.
2020
* Set<K> keySet() Returns set of all keys.
2121
* Collection<V> values() Returns Collection of all values.
2222
*/

0 commit comments

Comments
 (0)