Best way to duplicate lists in java

0
I'm new to this java thing. What is the best way to duplicate lists in java? @Override public java.util.List<IMendixObject> executeAction() throws Exception { this.list_input = new java.util.ArrayList<myfirstmodule.proxies.test>(); if (__list_input != null) for (IMendixObject __list_inputElement : __list_input) this.list_input.add(myfirstmodule.proxies.test.initialize(getContext(), __list_inputElement)); // BEGIN USER CODE IContext context=getContext(); java.util.List<IMendixObject> list_output=new ArrayList<IMendixObject>(); //createski for (int i=0;i<list_input.size();i++){ IMendixObject obj_output=Core.instantiate(getContext(),"MyFirstModule.test"); obj_output=list_input.get(i).getMendixObject(); list_output.add(obj_output); } return list_output;//null; // END USER CODE } Thankyou
asked
1 answers
1

define "best": your implementation seems fine, what are you looking for?

The only thing that's weird is that you Core.instantiate an empty object, I believe you can remove that and replace

IMendixObject obj_output=Core.instantiate(getContext(),"MyFirstModule.test");
obj_output=list_input.get(i).getMendixObject();

directly with

IMendixObject obj_output=list_input.get(i).getMendixObject();

I also believe that you don't use the context you create a var for at line 1:

IContext context=getContext();
answered