Why Java String class is declared as final?

0 votes

Can someone help me to understand why String class in Java is declared as final?

Aug 21, 2018 in Java by 93.lynn
• 1,560 points
68 views

1 answer to this question.

0 votes

String class is made final in Java in order to make the String objects immutable. Making an object immutable helps in two ways:

  1. Security: the system can hand out sensitive bits of read-only information without worrying that they will be altered
  2. Performance: immutable data is very useful in making things thread-safe.
answered Aug 21, 2018 by code.reaper12
• 3,450 points

Related Questions In Java

0 votes
2 answers

What is the use of final class in java?

In Java, items with the final modifier cannot be ...READ MORE

answered Oct 5, 2018 in Java by Daisy
• 8,050 points
52 views
0 votes
2 answers
0 votes
1 answer
0 votes
1 answer

Why Object is Super Class in Java?

Object is an exception to the first rule, ...READ MORE

answered Feb 7 in Java by Dheeraj
35 views
0 votes
3 answers

Check if a String is numeric in Java

Java 8 Lambda Expression is used: String someString ...READ MORE

answered Sep 3, 2018 in Java by Daisy
• 8,050 points
726 views
0 votes
2 answers

Generate an alpha-numeric string randomly

Java supplies a way of doing this ...READ MORE

answered Jul 18, 2018 in Java by Daisy
• 8,050 points
222 views
0 votes
1 answer

How do I create a Java string from the contents of a file?

If you're looking for an alternative that ...READ MORE

answered Apr 19, 2018 in Java by Rishabh
• 3,540 points
95 views
0 votes
2 answers

Counting no of Occurrence of a particular character inside a string in Java

We can find out the no. of ...READ MORE

answered Sep 7, 2018 in Java by Sushmita
• 6,880 points
281 views
0 votes
1 answer

Purpose of “String args[]” in the “psvm” of Java

Let me give you the complete explanation ...READ MORE

answered May 7, 2018 in Java by code.reaper12
• 3,450 points
93 views
0 votes
1 answer

Need for finalize() in Java

finalize() is a method called by the ...READ MORE

answered May 8, 2018 in Java by code.reaper12
• 3,450 points
81 views