/home/caleb/ASDV-Java/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/WildCard.java |
nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
package edu.slcc.asdv.caleb.lab6_generics_calebfontenot;
public class WildCard {
public static double max(GenericStack<? extends Number> stack) {
double max = Double.MIN_VALUE;
while (!stack.isEmpty()) {
double value = stack.pop().doubleValue();
if (value > max) {
max = value;
}
}
return max;
}
public static void main(String[] args) {
GenericStack<Integer> intStack = new GenericStack<>();
intStack.push(1);
intStack.push(2);
intStack.push(-2);
System.out.print("The max number is " + max(intStack));
}
}