I am currently working on a project where I have to make some method generic (to make the code more readable).
The projects has two classes: Box and MyList.
The constructor for ‘Box’ accepts to generic parameters; the constructor for ‘MyList’ only one.
public class Box<A, B> {}
That is the class for the box.
public class MyList<T> {}
And thats the class for MyList.
In the class ‘Box’ I have a method that looks like this:
public static MyList enclose (Box <MyList <Integer, String>> t) {
// Here comes some code that is not important right now.
}
What I want now, is to make this method generic so that it not only takes in parameters like a Box. Has anyone an idea?
It is not completely clear what you want to do, and the number of generic parameters do not match your classes but maybe this does the work?
Or if you want to avoid talking about MyList, maybe this:
The second version has the type of the first generic parameter of the
Boxobject as its return type…