X1032: Generics - Creating a Box

Using the Box class described in the reading assignment, create an instance of Box that can hold the value 4.2, then return that Box.

Here is the Box class again:

  public class Box<T>
  {
      private T value;

      public Box(T val)
      {
          value = val;
      }

      public T getValue()
      {
          return value;
      }

      public void setValue(T val)
      {
          value = val;
      }
}

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.