Array type expected; found: 'java.util.List
时间: 2024-05-26 15:11:33 浏览: 17
我理解你的问题是关于编程中类型错误的。你遇到了错误:期望数组类型,但是发现的是Java的列表类型。这是因为在Java中,数组和列表都表示了一系列的元素,但是它们的内部实现和语法不同。如果你想使用数组,你必须在声明中指定数组的类型和大小,而使用列表则不需要。建议你检查代码中的语法错误,确保变量类型的一致性。
相关问题
Array type expected; found: 'java.lang.String'
这个错误通常代表着您在代码中使用了错误的类型或数据结构。例如,在Java中,如果您编写了一个需要使用数组的方法,但传递给该方法的参数是一个字符串而不是数组,就会导致这个错误。您需要检查您的代码和方法参数,并确保它们使用正确的数据类型和数据结构。如果您需要更具体的帮助,请提供更多上下文信息,我会尽力帮助您。
java array type expected_构造函数定义为取String但方法调用显示错误'Array type expected found found java.lang.String' (...
这个错误通常是因为在方法调用时,传递的参数类型和方法定义时的参数类型不一致所导致的。请确保您在方法调用时传递的参数类型与方法定义时的参数类型相匹配。
在您的情况下,错误提示显示了 "Array type expected found found java.lang.String",这意味着您可能在方法参数中错误地使用了一个数组类型,而实际上您应该使用一个字符串类型。
例如,如果您的构造函数定义如下:
```
public MyClass(String[] myStrings) {
// constructor code
}
```
那么您在调用该构造函数时应该使用一个字符串数组作为参数,像这样:
```
String[] myStrings = {"string1", "string2", "string3"};
MyClass myObject = new MyClass(myStrings);
```
如果您想要传递一个字符串而不是一个字符串数组,请修改您的构造函数定义如下:
```
public MyClass(String myString) {
// constructor code
}
```
然后在调用该构造函数时,传递一个字符串作为参数,像这样:
```
String myString = "Hello world";
MyClass myObject = new MyClass(myString);
```
希望这可以帮助您解决问题!
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)