java - 为什么我收到错误 "Type Mismatch"?

标签 java

当我尝试在主类中初始化构造函数时,出现类型不匹配的错误。

public class Test_array 
{
    int arr[];
     Test_array()
      {
          arr=new arr[];     
      }


  public static void main(String[]args)
  {

  }
}

class RecTest 
{
int values[];
RecTest() 
{
values = new int[10];
}

}

最佳答案

arr 是变量名称而不是类型

arr = new int[10];

关于java - 为什么我收到错误 "Type Mismatch"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29336044/

相关文章:

java - 为什么java(maven)在编译过程中关心文件时间戳?

Java 代码将新对象的先前条目覆盖到队列数组中

JAVA : How to see the difference in output between a synchronized and normal thread counter?

java - 使用 maven2 构建 java 项目的问题

javascript - Selenium-Java-geckodriver : Test Execution halts with JavaScript error as "document.getElementById(...) is null"

java - @BeforeClass 在 eclipse 中为同一个类运行多次

java - 如果一个分区受到限制,如何对 kafka 中的剩余分区应用循环法

java - HTTP 400 从 Apache HTTP 客户端执行多部分请求时

java - Spring boot 在 Eclipse + Ubuntu 上失败

java - 从 ArrayList 中删除具有特定名称的项目