cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the First and last values in queue

0 Kudos

Hi,

We have a requirement to get the first and last values from one element for target 2 elements.

I wrote a udf for get the first value as below

public void getItem1(String[] a, ResultList output1, Container container) throws StreamTransformationException{

for(int i=0;i<a.length;i++)

{

if(a[i].length()>0)

{

String str1[]= a[i].split("\\,");

output1.addValue(str1[0]);

}

else

{

output1.addValue("");

}

}

and it is working fine.Now i want to get the last value as output,

Example:

In a element we getting some values with separate comma like 455657656,22323,76576,71236,98098,.......,67676.

I want to get the last value after the comma 67676 as a output.

Can you please help me on this.

Thanks in advance.

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Hi Guys,

I solved the issue by own.Here is the UDF to get the last value.

String str = var1.toString();
String a[]= str.split(",");
int len = a.length;

return a[len-1];


Thanks,