Saturday, October 28, 2017

"foreach" for Java

This is the "foreach" for Java.
You can test this code here: online java tester

import java.util.ArrayList;

public class HelloWorld
{
  public static void main(String[] args)
  {
    ArrayList<String> arry = new ArrayList<>();
    arry.add(new String("test1"));
    arry.add(new String("test2"));
    arry.add(new String("test3"));

    //foreach
    for(String value : arry) {
      System.out.println(value);
    }


  }
}