Skip to content

Commit 791e0e9

Browse files
committed
toString method added to Entry
1 parent df3c274 commit 791e0e9

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/Lists/ArrayListCustom.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,7 @@ public void forEach(Consumer<T> o) {
124124
public ArrayListCustom<T> filter(Predicate<T> o) {
125125
Objects.requireNonNull((o));
126126
ArrayListCustom<T> newList = new ArrayListCustom<>();
127-
this.forEach((item) -> {
128-
if (o.test(item)) {
129-
newList.add(item);
130-
}
131-
});
127+
this.forEach(o::test);
132128
return newList;
133129
}
134130

src/Maps/HashMapCustom.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public V getValue() {
3232
return this.val;
3333
}
3434

35+
@Override
36+
public String toString() {
37+
return "{ "+key+" = "+val+" }";
38+
}
3539
}
3640

3741
private int hashCode(K key) {
@@ -189,9 +193,7 @@ public Object[] toKeyArray() {
189193

190194
public Set<Entry<K, V>> entrySet() {
191195
Set<Entry<K, V>> set = new HashSet<>();
192-
forEachEntry(entry -> {
193-
set.add(entry);
194-
});
196+
forEachEntry(set::add);
195197
return set;
196198
}
197199

0 commit comments

Comments
 (0)