Write a generic method named add
with an upper bound (extends
).
The method should take two generic arguments and return the sum of the given two numbers.
add
method inside the main
method, passing appropriate data types.add
method.
Write a method named printOnlyIntegerClassorSuperClass
that takes a list as a lower bound (super
) Number
argument.
printOnlyIntegerClassorSuperClass
in the main
method and print the result.
Write a method named printwithextend
that takes a list as an upper bound (extends
) Number
argument.
printwithextend
in the main
method and print the result.
Write a method named printlist
that takes a list with an unknown bound (?
) as an argument.
printlist
in the main
method and print the result.
Write a method named sum
that takes a list as an upper bound (extends
) argument.
sum
in the main
method and print the result.Sum of two integers: 30 Sum of two doubles: 13.5 Printing Integer or SuperClass list: [10, 20, 30] Printing with Upper Bound list: [1.5, 2.5, 3.5] Printing Unbounded list: [A, B, C] Sum of Upper Bound list: 7.5