2013-04-16 48 views
0

我在我的eclipse上添加了commons-primitives-1.0.jar作爲外部可執行文件jar。
所以我能夠import org.apache.commons.collections.primitives.ArrayUnsignedShortList;Java apache commons collections原語導入問題

,我有一個功能

private void start() { 

    _nexts = new ArrayList(_iterators.size()); 

    for (int i = 0, m = _iterators.size(); i < m; i++) { 
     _nexts.add(null); 
    } 
    _nextSet = new BitSet(_iterators.size()); 
    _prevFrom = new ArrayUnsignedShortList(); < ---give me error here 
} 

它說,

構造ArrayUnsignedShortList()是不可見的

我不是相當肯定如何去解決這個錯誤,因爲當我看着ArraysUnsignedShortList.java,它確實有構造函數。

幫助?

http://commons.apache.org/proper/commons-primitives/apidocs/org/apache/commons/collections/primitives/ArrayUnsignedShortList.html

公共ArrayUnsignedShortList() 構造具有默認的初始容量的空列表。

^,所以我應該能夠把它..

+0

@rkosegi是,根據[文檔】(http://commons.apache.org/proper/commons-primitives/apidocs/org/apache/commons/collections/primitives/ArrayUnsignedShortList.html# ArrayUnsignedShortList \(\))。 –

+0

不一定相關,但'_prevFrom'的聲明類型是什麼? –

+0

@Paul,該文件說構造函數是公共的。所以他應該可以使用它。 –

回答

0

應該做工精細,不知道你有正確的庫,以正確的進口,並沒有什麼可以在你的代碼的干擾:

如果使用Maven:

<dependency> 
    <groupId>commons-primitives</groupId> 
    <artifactId>commons-primitives</artifactId> 
    <version>1.0</version> 
</dependency> 

導入:

import org.apache.commons.collections.primitives.ArrayUnsignedShortList; 

代碼:

ArrayUnsignedShortList myArray = new ArrayUnsignedShortList(); 
+0

嗯我不太清楚爲什麼我有這個錯誤。你的sugesstion不能解決我的問題。 – ealeon

+0

那麼要麼你沒有使用正確的版本(自定義軟件包?)和你正在使用的那個沒有'public'沒有參數的構造函數,或者eclipse失敗並且報告它不應該報告的錯誤。我可以確認,使用maven(公共回購)提供的版本可以正常工作。我使用Netbeans btw。 –

0

下載JAR從here

導入罐子到項目,並用這個,,做工精細。

ArrayUnsignedShortList obj = new ArrayUnsignedShortList(); 
+0

grrr這應該工作,但它只是不會。如果它沒有看到它,我甚至不能導入,但我可以導入正常。我只是不明白:( – ealeon

+0

什麼事情發生亞爾?你是如何導入這個罐子到您的項目? – gks

+0

我做了ArrayUnsignedShortList mine = new ArrayUnsignedShortList();仍然說它不可見與你的jar我猜猜問題不是因爲你可以使用它。idk在哪裏查明問題 – ealeon