final variable

You can specify an end variable using the reserved word final. The final variable represents a constant value that can not be changed. Typically, final variables are capitalized.

final int MAX = 100;
final int MIN = 1;

To access class variables and object property variables, use “.” As shown below.

ClassName.ClassVariable
class variable
ObjectName. ObjectPropertyVariable
object property variables
class A {
  int aa;
  int bb;
  int cc;
  static int s = 0;
}

class ATest {
  public static void main(String args[]) {
    A obja = new A();
    obja.aa = 4;
    obja.bb = obja.aa * 2;
    obja.cc = A.s;
  }
}
Basic example of an end variable

Leave a Reply

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

Latest Post