Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Arraylist发布ArrayListName.add(新的ArrayListName(…);_Java_Arraylist_Add - Fatal编程技术网

Java Arraylist发布ArrayListName.add(新的ArrayListName(…);

Java Arraylist发布ArrayListName.add(新的ArrayListName(…);,java,arraylist,add,Java,Arraylist,Add,我下载了一个名为comments的ArrayList文件,我对数组有基本的了解,我知道如果你想在数组中添加一些东西 comments.add(author, text, rating); 但我看到了一些别的或新的东西,我无法理解它 comments.addnewcommentauthor、text、rating 数组与ArrayList不同 从你的问题来看,我想你对arraylist有意见。有多种方法可以创建对象。在您的代码中,它是在一行中创建并添加到列表中的 //Create a n

我下载了一个名为comments的ArrayList文件,我对数组有基本的了解,我知道如果你想在数组中添加一些东西

comments.add(author, text, rating);
但我看到了一些别的或新的东西,我无法理解它


comments.addnewcommentauthor、text、rating 数组与ArrayList不同

从你的问题来看,我想你对arraylist有意见。有多种方法可以创建对象。在您的代码中,它是在一行中创建并添加到列表中的

    //Create a new comment
    Comment comment = new Comment(author, text, rating);

    //Add comment to comments arraylist
    comments.add(comment)  which is same as

    //Other way to add to list 
    comments.add(new Comment(author, text, rating));

请参加,访问并阅读,以了解如何有效地使用此网站。问题的形式我下载了一些代码,请解释给我是离题的。这不是一个教程或讨论站点。我投票将这个问题作为非主题来结束,因为这是关于Java和基本数据结构的基本理解。网上有很多这样做的资源。谢谢,我得到了帮助。