Java String interning

0 votes

Can someone explain, what is String Interning in Java and whats its purpose?

Oct 25, 2018 in Java by 93.lynn
• 1,600 points
867 views

1 answer to this question.

0 votes

The String.intern() method of Java Strings ensures that all strings contain the same content and share the same memory. 

For example, if you have a list of fruits, in which apple occurs 100 times, then with the help of String Interning you can ensure that only one apple is an actually allocated to the memory.

It's an important Java function that helps a lot in saving up the memory space.

For more details, you can refer here:​ http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#intern()

answered Oct 25, 2018 by geek.erkami
• 2,680 points

Related Questions In Java

0 votes
2 answers

How can I convert a String variable to a primitive int in Java

 Here are two ways illustrating this: Integer x ...READ MORE

answered Aug 20, 2019 in Java by Sirajul
• 59,230 points
2,354 views
0 votes
2 answers

Integer to String conversion in java

We can do this in 2 ways: String ...READ MORE

answered Jul 28, 2018 in Java by samarth295
• 2,220 points
1,232 views
0 votes
3 answers

String to Double conversion in java

Double temp = Double.valueOf(str); number = temp.doubleValue(); READ MORE

answered Sep 10, 2018 in Java by Sushmita
• 6,920 points
1,745 views
0 votes
4 answers

Remove extra spaces from string in java

import java.util.regex.Matcher; import java.util.regex.Pattern; String pattern="[\\s]"; String replace=""; part="name=john age=13 year=2001"; Pattern ...READ MORE

answered Sep 10, 2018 in Java by Parth
• 4,640 points
3,103 views
0 votes
2 answers

what is the best way to convert an ArrayList to a String

You could probably use the Joiner class ...READ MORE

answered Aug 19, 2019 in Java by Sirajul
• 59,230 points
1,326 views
0 votes
1 answer

Default Object.toString() in hashcode

Well, the hash code object is the ...READ MORE

answered Oct 31, 2018 in Java by code.reaper12
• 3,500 points
1,064 views
+5 votes
4 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

answered Mar 27, 2018 in Java by DragonLord999
• 8,450 points

edited Nov 7, 2018 by Omkar 81,375 views
+1 vote
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,500 points
8,402 views
0 votes
2 answers

How to convert ArrayList<String> to String[] in Java

Try this:  String[] strArray = arrayList.toArray(new Str ...READ MORE

answered Aug 21, 2019 in Java by Sirajul
• 59,230 points
1,022 views
0 votes
2 answers

Java enum lookup using a String

Check this...Java Enum in details READ MORE

answered Dec 4, 2018 in Java by allenvarna
• 540 points
994 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP