X467: Generic Class Basics

Using generics in your program can be very useful considering generic methods and generic classes can handle different datatypes. Practice using generics by completing the class Answer:

  • Add a private generic field named value
  • Add a public void setter method setValue(T newValue) with a generic parameter and sets the field value to the parameter
  • Add a public getter method getValue() that returns the field value.

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.