日期:2014-05-20 浏览次数:20911 次
class Vertex { List<Integer> adj = new ArrayList<Integer>(); } Vertex[] v = new Vertex[n]
List<Integer>[] adj = new List<Integer>[n]; for (List<Integer> lst: adj) lst = new ArrayList<Integer>()
package test; import java.util.ArrayList; import java.util.List; public class Vertex { List<Integer> adj = new ArrayList<Integer>(); public static void main(String[] args) { int n = 10, i = 0; Vertex[] v = new Vertex[n]; v[i] = new Vertex(); v[i].adj.add(10); } }
------解决方案--------------------