Google Analytics

Thursday, September 25, 2014

Java New Loop

Observed the code from:
http://alvinalexander.com/java/java-string-array-reference-java-5-for-loop-syntax

public class JavaStringArrayTests2
{
  private String[] toppings = {"Cheese", "Pepperoni", "Black Olives"};
  // our constructor; print out the String array here
  public JavaStringArrayTests2()
  {
    <b>for (String s: toppings)
    {
      System.out.println(s);
    }</b>
  }
  // main kicks everything off.
  // create a new instance of our class here.
  public static void main(String[] args)
  {
    new JavaStringArrayTests2();
  }
}

No comments:

Post a Comment