# Iterating on a list and retrieving the values

## About this task

This scenario describes a two component Job in which a list is created and iterated upon in a tForeach component. The values are then retrieved in a tJava component.

## Setting up the Job

### Procedure

1. Drop a tForeach and a tJava component onto the design workspace.
2. Link tForeach to tJava using a Row &gt; Iterate connection.

### Results

![](https://help.qlik.com/talend/en-US/components/8.0/Resources/images/tForeach_scenario_components.png)

## Configuring the components

### Procedure

1. Double-click tForeach to open its Basic settings view:

   ![](https://help.qlik.com/talend/en-US/components/8.0/Resources/images/tForeach_scenario_basic_settings.png)
2. Click the [+] button to add as many rows to the Values list as required.
3. Click on the Value fields to enter the list values, between double quotation marks.
4. Double-click tJava to open its Basic settings view:

   ![](https://help.qlik.com/talend/en-US/components/8.0/Resources/images/tForeach_scenario_tJava_basic_settings.png)
5. Enter the following Java code in the Code area: System.out.println(globalMap.get("tForeach\_1\_CURRENT\_VALUE")+"\_out");

## Saving and executing the Job

### Procedure

1. Press Ctrl+S to save your Job.
2. Press F6 to execute the Job.

### Results

The tJava run view displays the list values retrieved from tForeach, each one suffixed with \_out:

![](https://help.qlik.com/talend/en-US/components/8.0/Resources/images/tforeach_scenario_tjava_run_view.png)

**Related reference**

* [tForeach](https://help.qlik.com/talend/en-US/components/8.0/orchestration/tforeach "Creates a loop on a list for an iterate link.")

**Related information**

* [tJava](https://help.qlik.com/talend/en-US/components/8.0/java-custom-code/tjava)