13. (5 marks) Rewrite or fix the Trio class to make proper use of Java Generics.
ID: 3915548 • Letter: 1
Question
13. (5 marks) Rewrite or fix the Trio class to make proper use of Java Generics. In your solution it should be possible for the data fields to be different types. public class Triof private Object onei private Object two private Object three: public Trio (Object one, Object two, object three) t this.one one: this.two two; this.three - three: public Object getone ) (return one;) public Object getTwo() (return two:) public Object getThree 0 (return three:) public void setOne (Object one) (this.one one: public void setTwo (Object two) (this.twotwo; public void setThree (object three) (this.three - three;)Explanation / Answer
public class Trio { private T1 one; private T2 two; private T3 three; public Trio(T1 one, T2 two, T3 three) { this.one = one; this.two = two; this.three = three; } public T1 getOne() { return one; } public T2 getTwo() { return two; } public T3 getThree() { return three; } public void setOne(T1 one) { this.one = one; } public void setTwo(T2 two) { this.two = two; } public void setThree(T3 three) { this.three = three; } }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.