![]() |
#1 |
Registered User
Join Date: Dec 2014
Posts: 93
|
Why String is final in Java?
Hi friends,
I would like to know, Why String is final in Java?
__________________
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. |
![]() |
![]() |
![]() |
#2 |
Registered User
Join Date: Oct 2017
Posts: 16
|
String is a very core class in Java, many things rely on it working a certain way, for example being immutable. Making the class final prevents subclasses that could break these assumptions. Note that, even now, if you use reflection, you can break Strings (change their value or hashcode).
__________________
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. |
![]() |
![]() |
![]() |
#3 |
Registered User
Join Date: Nov 2017
Posts: 156
|
String is a very core class in Java, many things rely on it working a certain way, for example being immutable. Making the class final prevents subclasses that could break these assumptions. Note that, even now, if you use reflection, you can break Strings (change their value or hashcode)
__________________
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. |
![]() |
![]() |
![]() |
#4 |
Registered User
Join Date: Sep 2017
Posts: 177
|
String is a very core class in Java, many things rely on it working a certain way, for example being immutable. Making the class final prevents subclasses that could break these assumptions. Note that, even now, if you use reflection, you can break Strings (change their value or hashcode).
|
![]() |
![]() |
![]() |
#5 |
Registered User
Join Date: Sep 2015
Location: UK
Posts: 447
![]() |
Once you assign a string object, that object can not be changed in memory. In summary, what you did is to change the reference of "a" to a new string object. Java String is immutable, String will Store the value in the form of object.
|
![]() |
![]() |
![]() |
#6 |
Registered User
Join Date: Sep 2017
Posts: 177
|
String is a very core class in Java, many things rely on it working a certain way, for example being immutable. Making the class final prevents subclasses that could break these assumptions. Note that, even now, if you use reflection, you can break Strings (change their value or hashcode).
|
![]() |
![]() |
![]() |
#7 |
Registered User
Join Date: Jul 2017
Posts: 86
|
String is a very core class in Java, many things rely on it working a certain way, for example being immutable. Making the class final prevents subclasses that could break these assumptions. Note that, even now, if you use reflection, you can break Strings
__________________
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. |
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
JAVA Projects 2016 | AcademicProject | Java | 2 | 09-21-2017 02:05 AM |
Is String a data type in java? | Kunal | Java | 1 | 03-18-2016 10:46 PM |
Final Year JAVA Projects | AcademicProject | Post your ad here | 0 | 02-01-2016 02:12 AM |
The conclusion provided by the Black Hat Java Script | andrebreton2121 | Search Engine Optimization | 6 | 10-17-2012 11:06 PM |
biggest teature of String in java? | cianfie | Java | 0 | 12-08-2011 09:03 PM |