爲什麼我不能做:錯誤添加字節中的LinkedList <Byte>
Byte b = new Byte("0");
LinkedList<Byte> begin = new LinkedList<Byte>().add(b);
爲什麼我不能做:錯誤添加字節中的LinkedList <Byte>
Byte b = new Byte("0");
LinkedList<Byte> begin = new LinkedList<Byte>().add(b);
由於new LinkedList().add(b);
的結果不是LinkedList
。它是boolean
。
嘗試
List<Byte> begin = new LinkedList<Byte>();
byte b = 0;
begin.add(b);
如果你想字節集合出現了一批收藏它們這樣做更有效的。例如LinkedList將使用您添加的每個字節約20個字節。嘗試使用
new LinkedList()。add(b);犯規返回一個LinkedList對象 嘗試
Byte b = new Byte("0");
LinkedList<Byte> list= new LinkedList<Byte>();
list.add(b);
LinkedList<Byte> begin = new LinkedList<Byte>()
begin.add(b);
如何初始'begin'與細則( 「0」)? – Mehdi
如果你確實需要在一行中做到這一點,請執行:'new LinkedList(java.util.Arrays.asList((byte)0));'' –
LuGo