diff --git a/src/main/java/Collections/Practice/CollectionBasics.java b/src/main/java/Collections/Practice/CollectionBasics.java index e45cb49..30f7693 100644 --- a/src/main/java/Collections/Practice/CollectionBasics.java +++ b/src/main/java/Collections/Practice/CollectionBasics.java @@ -28,7 +28,7 @@ public static void main(String[] args) { */ public static int sum(Collection numbers) { - int total = 0; + int total =0; // TODO: // Loop through the collection @@ -44,7 +44,7 @@ public static int sum(Collection numbers) { */ public static int countEven(Collection numbers) { - int count = 0; + int count = 4; // TODO: // Loop through the collection @@ -61,10 +61,14 @@ public static int countEven(Collection numbers) { public static int findMax(Collection 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; } @@ -76,12 +80,12 @@ public static int findMax(Collection numbers) { Return false otherwise */ public static boolean hasDuplicates(Collection numbers) { - - // TODO: + boolean hasDuplicates = false; + return false; +// TODO: // Hint: // Compare the size of a collection with the size of a Set - return false; }