私はJavaのジェネリックスで作業を始めました。生のタイプ/ Tを解決できません
まず第一に、私は、パラメータを必要とする生タイプのいくつかの読み取りを行なったし、彼らは一般的なものですので、やることが多くはありません実現が、私の問題はBagInterface
とLinkedBag
との間の相互作用である:
package Chapter3;
public interface BagInterface<T> {
/** Gets the current number of entries in the bag.
* @return the integer number of entries in the bag. */
public int getCurrentSize();
/** Sees whether this bag is full.
*@return true if the bag is full, or false if not. */
public boolean isFull();
/** Sees whether the bag is empty.
*@return true if bag is empty, or false if not. */
public boolean isEmpty();
/** Adds new entry to this bag.
*@param newEntry the object to be added as a new entry
*@return if the addition was successful, or false if not. */
public boolean add(T newEntry);
/** Removes one unspecified entry from this bag, if possible.
*@return either the removed entry, if the removal was successful, or null. */
public T remove();
/** Removes one occurrence of a given entry from this bag.
*@param anEntry the entry to be removed
*@return true id the removal was successful, or false if not. */
public boolean removal(T anEntry);
/** Removes all entries from this bag. */
public void clear();
/** Counts the number of times a given entry appears in this bag.
*@param anEntry the entry to be counted
*@return the number of times anEntry appears in the bag. */
public int getFrequencyOf(T anEntry);
/** Tests whether this bag contains a given entry.
*@param anEntry the entry to locate
*@return true if this bag contains anEntry, or false if not. */
public boolean contains(T anEntry);
/**Retrieves all entries that are in this bag.
*@return a newly allocated array of all the entries in the bag */
public T[] toArray();
}
2つのエラーが持っています解決されていないTをどうする
package Chapter3;
public class LinkedBag implements BagInterface {
// reference to first node
private Node firstNode;
private int numberOfEntries;
// default constructor
public LinkedBag() {
firstNode = null;
numberOfEntries = 0;
}
// second constructor
(error occurs here) public LinkedBag(T[] item, int numberOfItems) {
this();
for(int index = 0; index < numberOfItems; index++)
add(item[index]);
}`
他get.dataと一緒にいるが、私はまた、Tは
を解決していないに関係していると信じています(error occurs here) result[index] = currentNode.getData();
index++;
currentNode = currentNode.getNextNode();
}// end while
return result;
}// end is full
詳細情報が必要な場合は、完全な.javaファイルを書き留めておきますが、具体的かつ簡潔にしておきます。
どのようなエラーが表示されますか?正確なテキストを共有できますか? Tの – Mureinik
エラーがのgetData上 エラー() 「Tタイプに解決することはできません」 あり、このエラーを生成何行 – DR4QU3
「タイプのLinkedBag.Nodeから法のgetData()不足しているタイプTを指し、」? – Mureinik