What is Instance Variable?

What is Instance Variable?

Instance Variable is a variable that is defined within a class, and it exists as long as the object exists. An example is the Bee class, which has two variables nectarCapacity and maxNectarCapacity:

public class Bee {

    * Current nectar capacity
   private double nectarCapacity;

    * Maximal nectar that can take bee.
   private double maxNectarCapacity = 20.0;


Оцените статью
Добавить комментарий

Your email address will not be published. Required fields are marked *