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
23 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,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,310 points
45 views
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
49 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,820 points
35 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 parth295
• 4,590 points
49 views
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,220 points
31 views
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
21 views
+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,360 points

edited Nov 6, 2018 by Omkar 4,610 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,030 points
1,232 views
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
49 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
• 520 points
44 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.