Nice TWiki > Doc > CodeExamples > CollectionExample TWiki webs:
Dev | Doc | Main | TWiki | Sandbox
Doc . { Changes | Index | Search | Go }
package test;

void main(String[] args)
{
  java.util.List<String> frenchNumbers = new ArrayList();
  frenchNumbers.add("Zero");
  frenchNumbers.add("Un");
  frenchNumbers.add("Deux");
  frenchNumbers.add("Trois");
  frenchNumbers.foreach(String s => println(s));

  // Collections can be used on primitive types too (unlike Generic Java).
  java.util.List<int> numbers = new ArrayList();
  numbers.add(0);
  numbers.add(1);
  numbers.add(2);
  numbers.add(3);
  numbers.foreach(int i => println("Number " + i + " is written " + frenchNumbers[i] + " in french."));
}

As an anecdote, this was the first published piece of code after Nice accepted Java collections with generic types.

-- DanielBonniot - 06 Jun 2003

Topic CollectionExample . { Edit | Attach | Ref-By | Printable | Diffs | r1.1 | More }
Revision r1.1 - 06 Jun 2003 - 18:22 GMT - DanielBonniot
Parents: WebHome > CodeExamples
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback.