将对象添加到另一个类中的对象数组

时间:2013-11-02 19:27:18

标签: java arrays methods

我看过一些论坛帖子,我知道java是Pass by Value。不过我对此仍然有点困惑。所以我的问题是,如果StoryFragment有一个注释数组,我想通过另一个具有addAnnotation方法的类在该数组中添加一个注释,那么我的代码将在下面工作吗?在StoryFragment中,我使用getter方法来接收注释数组。

public class StoryFragmentController {

public void addAnnotation(Annotation annotation, StoryFragment storyFragment){
    storyFragment.getAnnotations().add(annotation);
}

提前致谢。

0 个答案:

没有答案
相关问题