get count of string list for a particular string

Input is string list which contains multiple strings Ex values: Ram,Raj,Rahim,Rahim,Ram,Raj

When condition satisfies with Ram,get the count of Ram in the output.
Similar for Rahim and Raj

Thanks in advance,

Hi Niveditha,

There are many ways to achieve this requirement. One way is to use java service. Please see below steps.

1)In the designer create a Java Service (ex: “GetCountJava” ) (rt click-> New-> Java Service)

2)Select Input/Output tab
Add following variables in the input section:
a)Insert variable of type StringList (name it as “listOfNames” )
b)Insert variable of type String (name it as “searchName” )

Add the following variable in the output section:
a)Insert a variable of type String(name it as “count” )
(Please see attached image(1.png) for your reference )

  1. Now select source tab and use following code in the “GetCountJava” method
    IDataCursor pipelineCursor = pipeline.getCursor();
    String listOfNames = IDataUtil.getStringArray( pipelineCursor, “listOfNames” );
    String searchName = IDataUtil.getString( pipelineCursor, “searchName” );
    int count=0;
    for (String string : listOfNames) {

     IDataUtil.put( pipelineCursor, "count", count );

(Please see attached image(2.png))

The above code will read list of names and a name which is used to match against the list. Whenever there is a match count variable is incremented.

4)Run the service and input list of names and name in the input section(result1.png . The output will give the count.
(Please see attached image result1.png)

Please revert back if you need any assistance.