04
Jul
You can use unbounded wildcards, bounded wildcards, or lower-bound wildcards to specify a range for a generic type. What are wildcard generic types and why are they needed? The code below gives an example todemonstrate the needs. The example defines a generic max method for finding the maximum in a stack of numbers (lines 15–25). The main method creates a stack of integer objects, adds three integers to the stack, and invokes the max method to find the maximum number in the stack. The program above has a compile error in line 11 because intStack is not an instance of…