public class Matrix<TValue, TList extends List<E>> {
private TList<TList<TValue>> items;
}
I want to use 2 instances of Matrix class. One with ArrayList<Integer> and second with LinkedList<Integer>.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Unfortunately, it is very difficult to code a generic object wich contains a list of lists the way you want to.
This is because of type erasure in java wich means:
However, if the types of lists you want to use is small, you can do something similar to this example (this one is limited to ArrayList and LinkedList):
This can be easily initialized and used: