cancel
Showing results for 
Search instead for 
Did you mean: 

Generics in view's method

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

satish_kumar106
Explorer
0 Kudos

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.

Former Member
0 Kudos

Hi SAtish

Thank you for your answer. It did not occcur to me....

I have just checked it and it works.

Thank you very much !!!!.

regards

yuval peery

Answers (2)

Answers (2)

p330068
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

p330068
Active Contributor
0 Kudos

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