Fix final for fields.
Add a cast in for array length - it is always an int in java.