泛型:“未检查的作业”警告

时间:2020-03-28 01:19:59

标签: java generics intellij-idea

我的代码:

class Pattern
  {
  private Vector<Category>[] mCategories;

  private class Category
    {
    // ...
    }

  public Pattern(int numCat)
    {
    mCategories = new Vector[numCat];   // <-- Here I get the warning
    }
  }

IntelliJ给我警告

“未选中的分配”:java.util.Vector []到'java.util.Vector []'

做到

mCategories = new Vector<>[numCat];

不仅无济于事,而且给我一个错误“无法推断参数”

那么我该如何解决呢?

0 个答案:

没有答案
相关问题