I have this java code.
List myList = new ArrayList();
myList.add(\"Hello\");
myList.add(\"World\");
I need to loop
You can use <ui:repeat>:
<ui:repeat value="#{bean.myList}" var="value">
#{value} <br />
</ui:repeat>
If you're not sure if you should use <h:dataTable> or <ui:repeat>, you can check an example that mkyong provides here: JSF 2 repeat tag example
In short: <h:dataTable> renders a <table> HTML component, while <ui:repeat> gives you the flexibility to choose how to display the data.