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,550 points

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:​

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

Related Questions In Java

0 votes
1 answer

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

You can convert a String to int by using a function: int ...READ MORE

answered Apr 12, 2018 in Java by sharth
• 3,320 points
0 votes
2 answers

Integer to String conversion in java

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

answered Jul 27, 2018 in Java by samarth295
• 2,190 points
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,840 points
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 parth295
• 4,600 points
0 votes
1 answer

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

String lString = String.join(", ", list); In case ...READ MORE

answered Apr 26, 2018 in Java by developer_1
• 3,280 points
0 votes
1 answer

Default Object.toString() in hashcode

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

answered Oct 30, 2018 in Java by code.reaper12
• 3,450 points
+5 votes
3 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,380 points

edited Nov 6, 2018 by Omkar 6,127 views
0 votes
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,050 points
0 votes
1 answer

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

You can try using this: List<String> list = ...READ MORE

answered May 21, 2018 in Java by geek.erkami
• 2,320 points
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
• 520 points