Write a generic method that compares its 2 arguments using theequals method and returnstrue if they are
Fantastic news! We've Found the answer you've been seeking!
Question:
- Write a generic method that compares its 2 arguments using theequals method and returnstrue if they are equal andfalse otherwise.Ensure that the name of your method includes your last name.
- Use your generic method in a program that tests it with a variety of built-in types such asObject orInteger.
- Take a screenshot of your output and paste it into a new Word document under an "Exercise 1" heading.
- Below the screenshot in the Word document, briefly discuss the results that you saw when you ran the program. Did you see what you expected to see? Why or why not?
Exercise 2
- Write a generic classPair which has 2 type parameters,F andS, representing the type of the first and second elements of a pair respectively.
- Add get and set methods for the first and second elements of the pair.
- Override thetoString() method to display the first and second values of the pair in a format of your choosing.
- Use thePair class in a program that creates anArrayList of 10Pair objects containing values of your choosing. The program will then print the string representation of eachPair toSystem.out (i.e., use thetoString() method).
- Take a screenshot of your output and paste it into the Word document you created for the first exercise, but place the screenshot under a header for "Exercise 2."
Related Book For
Null Family Law Cases And Materials
ISBN: 9781599415741
5th Edition
Authors: Judith Areen , Milton C Regan
Posted Date: