Question: Java Program: Minimum Value Write a generic function FindSmallest() that returns the smallest value (minimum) in an ArrayList of numbers (Integers, Doubles, etc.) that is
Java Program: Minimum Value
Write a generic function FindSmallest() that returns the smallest value (minimum) in an ArrayList of numbers (Integers, Doubles, etc.) that is passed to it.
Hint: you will use the compareTo() method to compare the values in the function.
You will hardcode your ArrayLists.
For the sample code:
ArrayListone = new ArrayList (); one.add(4.5); one.add(45.2); one.add(14.5); one.add(3.14); one.add(4.5); one.add(450.0); System.out.println("The smallest value in: "+one+" is: "+FindSmallest(one));
The output should be:
The smallest value in: [4.5, 45.2, 14.5, 3.14, 4.5, 450.0] is: 3.14
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
