Insert Dimensions to complete Expression/ReferenceType

后端 未结 7 1804
醉话见心
醉话见心 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 23:01

    Satyendra Sharma's answer is absolutely correct, but here's some reasoning of what exactly the error message is saying.

    The error is caused by using a primitive type, which cannot be used as a generic type argument. For instance, List is incorrect, whereas List is correct. Wrapper classes can be used to wrap the primitive values and yield a reference type, which can be used with generics.

    Insert dimensions? What?

    The message "Insert dimensions to complete expression/referenceType" is probably because in order for the expression to become valid, the only valid token here is a set of square brackets.

    For instance,

    HashMap marked;
    

    will just compile fine. This is because, unlike a boolean, a boolean[] is an object.

提交回复
热议问题