我想克隆列表:如何克隆二維列表?
public List<List<Test>> a = new ArrayList<List<Test>>();
public List<List<Test>> b = new ArrayList<List<Test>>();
但是,如果我做的:
b = (ArrayList<List<Test>>)a.clone();
發生了錯誤:
The method clone() is undefined for the type List<List<Test>>
你能幫助我嗎?
必須覆蓋的clone()來自Object。一個相關的問題是http://stackoverflow.com/questions/869033/how-do-i-copy-an-object-in-java。 – user1929959