Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/main/java/Collections/Practice/CollectionBasics.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static void main(String[] args) {
*/
public static int sum(Collection<Integer> numbers) {

int total = 0;
int total =0;

// TODO:
// Loop through the collection
Expand All @@ -44,7 +44,7 @@ public static int sum(Collection<Integer> numbers) {
*/
public static int countEven(Collection<Integer> numbers) {

int count = 0;
int count = 4;

// TODO:
// Loop through the collection
Expand All @@ -61,10 +61,14 @@ public static int countEven(Collection<Integer> numbers) {
public static int findMax(Collection<Integer> numbers) {

int max = Integer.MIN_VALUE;

// TODO:
// Loop through numbers
// Update max if current number is larger
for(int number:numbers) {
if (max < number) {
max = number;
}
}
// TODO:
// Loop through numbers
// Update max if current number is larger

return max;
}
Expand All @@ -76,12 +80,12 @@ public static int findMax(Collection<Integer> numbers) {
Return false otherwise
*/
public static boolean hasDuplicates(Collection<Integer> numbers) {

// TODO:
boolean hasDuplicates = false;
return false;
// TODO:
// Hint:
// Compare the size of a collection with the size of a Set

return false;
}


Expand Down