0
what are static, constant and read-only
2 Antworten
+ 1
think of them like holding unchanging. values
the different is const need to initialize when we define it .and so the others
0
static:
Think, you have class name called bank account, your account number is constant, ur account balance is static.. where ever (in different instances of bank account class)u check the account balance it will be same..
static variables hold the same value irrespective of the instances of the class..
constant variables should be defined with the value while creating it..
read only variables can be accessed/retrieved the values using the class instances .. but other than the same class where it had been defined we cannot set the the values for the read only variables.
please correct me if I am wrong..