+ Reply to Thread
Results 1 to 4 of 4

Thread: What is the final variable?

  1. #1

  2. #2
    Hosting Guru ClaudiusMorales is on a distinguished road
    Join Date
    May 2020
    Location
    Los Angeles
    Posts
    61
    In Java, when final keyword is used with a variable of primitive data types (int, float, .. etc), value of the variable cannot be changed. For example following program gives error because i is final. final int i = 10 ; i = 30 ; // Error because i is final.

  3. #3
    HWHT Addict Cevious is on a distinguished road
    Join Date
    Jan 2021
    Location
    New Delhi
    Posts
    30
    First of all, final is a non-access modifier applicable only to a variable, a method, or a class.
    Following are different contexts where the final is used. Final variables.
    When a variable is declared with a final keyword, its value can't be modified

    Tally Prime |Download Tally Prime | Buy Tally Prime

  4. #4
    HWHT Starter Neo_5678 is on a distinguished road
    Join Date
    Dec 2020
    Location
    India
    Posts
    16
    A final variable can be explicitly initialized only once. A reference variable declared final can never be reassigned to refer to a different object. However, the data within the object can be changed.

+ Reply to Thread

Similar Threads

  1. What is the final variable?
    By invisionlandscape in forum Programming Discussion
    Replies: 4
    Last Post: 09-21-2020, 09:07 AM
  2. What is the final variable?
    By designpluz in forum Programming Discussion
    Replies: 0
    Last Post: 04-18-2019, 04:14 AM
  3. What is a final variable?
    By gitanistone in forum Programming Discussion
    Replies: 0
    Last Post: 02-28-2019, 10:27 AM
  4. What is a final variable?
    By sydneyearplug in forum Programming Discussion
    Replies: 0
    Last Post: 02-28-2019, 06:40 AM
  5. What is the final variable?
    By warrantyandinsurance in forum Programming Discussion
    Replies: 0
    Last Post: 12-27-2018, 03:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts