Insert Dimensions to complete Expression/ReferenceType

后端 未结 7 1806
醉话见心
醉话见心 2021-01-03 21:55

I\'m a newbie to Java.

I have provided a short snippet from my code for BFS.

public int bfs(Person p, Person q) {
    private HashMap

        
7条回答
  •  北海茫月
    2021-01-03 22:44

    Generic are resolved during compile time and during runtime their no context about the generic used in your code. The Object is than type cast into the class type provided against the generic type. Now both primitive and object are completely unrelated entities in java. Direct time-cast of Object to primitive type isn't possible in java. For this reason the use of primitive type in generic is disallowed and eclipse gives this warning.

提交回复
热议问题