Statements

Variable declaration

The general syntax of a variable declaration is the same as Java's, except that variable initialization is required:

    Type identifier = initializing_expression;

Examples:

    Int n = 10;
    String name = "zef";
    List<Int> lints = new List<Int>(1, 2, 3, 4);

As a convenience, PIL supports type inference for local variable declarations using the var keyword, so equivalent variable declarations would be:

    var n = 10;
    var name = "zef";
    var lints = new List<Int>(1, 2, 3, 4);

Assignment

Assignment in PIL is the same as in Java. Possible left-hand sides are variables, fields, field access and indexers:

    a = 3;
    a.findUser().name = "zef";
    ar[0] = 10;

Control structures

PIL has the same basic constrol structures as Java, including Java 5+'s for each. It supports: if, for and while:

    if(a > 0) {
      ...
    } else if(a < 0) {
      ...
    } else {
      ...
    }
    for(Int i = 0; i < 10; i++) {
      ...
    }
    for(Int n : new List<Int>(1, 2, 3, 4)) {
      ...
    }
    while(a > 0) {
      ...
    }

Exceptions

PIL supports unchecked exceptions, using Java's syntax:

    try {
       throw new Exception("An exception");
    } catch(Exception e) {
       ...
    } finally {
       ...
    }