Thursday, March 29, 2012

How do you make a variable read-only in Java?

How do you make a variable read-only in Java?
By using the keyword final.

E.g.:
      public final int id = 1234;

1 comment:

  1. http://stackoverflow.com/questions/14324805/class-variable-public-access-read-only-but-private-access-r-w

    ReplyDelete

Please, before starting to comment, evaluate if what you want to write is useful, respectful and positive. A kid may read this also.

Give a good example!