The method add(Object[]) in the type List Object[] is not applicable for the arguments (File).

约定不等于承诺〃 2022-04-03 03:26 321阅读 0赞

今天写Java读取目录下所有文件的实验时遇到一个错误:

The method add(Object[]) in the type List is not applicable for the arguments (File)

List类型中的方法add(Object[])不适用于参数(文件)

报错原因:

是因为List写成Object[]型了

  1. List<Object[]> fileList = new ArrayList<Object[]>();

解决方法:

改成File类型就好

  1. List<File> fileList = new ArrayList<File>();

发表评论

表情:
评论列表 (有 0 条评论,321人围观)

还没有评论,来说两句吧...

相关阅读