+ 4
Why is string final in Java?
8 Respuestas
+ 4
Yea i think i got the answer
The string is Immutable in Java because String objects are cached in String pool. Since cached String literals are shared between multiple clients there is always a risk, where one client's action would affect all another client. For example, if one client changes the value of String "Test" to "TEST", all other clients will also see that value as explained in the first example. Since caching of String objects was important from performance reason this risk was avoided by making String class Immutable. At the same time, String was made final so that no one can compromise invariant of String class by extending and overriding behaviours.
+ 1
Search about jvm memory and string pool and you will understand why string is imutable object . the objectif is to reduce memory space
+ 1
Talha altinel there's no multiple inheritance because you will have problem it's called Diamond noir you can search about it if you need help send me message and i will explain what's diamond
0
If you find James Gosling, ask this too. Why is there no multiple class inheritance in java? Isaiah Egbokhan
0
i think it an oopsie