Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.
String class is immutable. Its so because u will be having a number of reference variables pointing to single object, iff the object content is same of all those references variables..so if user tries to change or modify the content of the String..then this will be affecting all other reference variables pointing to the object. So this is the reason why String class is immutable.
This results in saving a lot of memory space as a no.of references variables can point to a single object if the content is same.
security reasons:
for opening network connections,you can pass host name,url as string
you can open any file in java by passing name of file as argument to File I/O classes.if string is not immutable this would lead serious security threat , I mean some one can access to any file for which he has authorization, and then can change the file name either deliberately or accidentally and gain access of those file.
Some of the important reasons are:
Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?