When assind fields or properties to a class you need to think about what attributes that a class has. Ideally you want to set the minimal amount of attributes. A super simple example would be a map. It can be divided into X for the width and Y for the height. You start adding fields by listing the protection level, the type and then finally the name.

Every field in a class has an accessibility level, meanind how protected they make the declared properties. Their are private, protected and public.

  • Public: The field can be accessed by any method in any class.

  • Private: The field can be accessed by only the same class they were declared in. This is the default value.

  • Protected: The field can be accessed by only the current class and subclasses

private int Width
private int Height

Next up we will cover how to use these fields with constructors.