on 12-02-2011 3:17 PM
Hi
I am working in CE 7.2 and I want to declare a method that returns ArrayList<String>.
How is it done?
regards
Yuval Peery
Hi Yuval,
You can simply create ArrayList return type. In the method which u pass & get parameter add the generics. I tried the below
example & it worked.
ArrayList<String> a = sample();
a.add("12");
public java.util.ArrayList sample( ) {
//@@begin sample()
ArrayList<String>asds= new ArrayList<String>();
return asds;
//@@end
}
Regards,
Satish S.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Yuval,
Please open the iview > method tab > new > method radio button > ENTER the name of method then click on button ... > select the Java native type > browse > search arraylist.
Best Regards
Arun Jaiswal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Arun
Thank you for your reply.
The problem is not Arraylist but ArrayList<String> , supported as of JDK 1.5.
Moreover when I try to add the generic type <String> to a function that has been
declared as returning ArrayList, the compiler automatically removes the addition of <String>.
public ArrayList myFunc() should be declared as public ArrayList<String> myFunc()
regards
yuval peery
Dear Yuval,
Please open the iview > method tab > new > method radio button > ENTER the name of method then click on button ... > select the Java native type > browse > search arraylist.
Best Regards
Arun Jaiswal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.