Help Center

Local Navigation

Avoiding unnecessary field initialization

Where possible, allow fields to initialize automatically as follows:

  • object references are initialized to null
  • int, byte, or long is initialized to 0
  • Boolean is initialized to false

You must explicitly initialize local variables in a method.

Code sample

class BetterExample {
private int fieldsCount;
private Field _fieldWithFocus;
private boolean _validLayout;
private boolean _validLayout;


Was this information helpful? Send us your comments.