Unsure how to write method in Java like template in c
<p>I want to implement a function with signature</p>

<pre><code>static boolean checkAnyOutOfBoundary(int[] index,ArrayList&lt;ArrayList&lt;T&gt;&gt; list)
</code></pre>

<p>Where I want to substitute T with other self-created class(DocScore). I tried to substitute T with Object. But when I try to instantiate the list instance, like</p>

<pre><code>ArrayList&lt;ArrayList&lt;Object&gt;&gt; DocScoreList = new ArrayList&lt;ArrayList&lt;Object&gt;&gt;();
for (int i = 0; i &lt; index.length; i++)
DocScoreList.add(root.children.get(i).docList);

The type of root.children.get(i).docList is ArrayList&lt;DocScore&gt;
</code></pre>

<p>I can not add element into DocScoreList. Does anybody know how can I implement this?</p>
