What is the difference between creating String as new () and literal?
Page 1 of 1
What is the difference between creating String as new () and literal?
When we create string with new () it’s created in heap and not added into string pool while String created using literal are created in String pool itself which exists in Perm area of heap.
String s = new String("Test");
will put the object in String pool , it it does then why do one need String.intern() method which is used to put Strings into String pool explicitly. its only when you create String object as String literal e.g. String s = "Test" it put the String in pool.
String s = new String("Test");
will put the object in String pool , it it does then why do one need String.intern() method which is used to put Strings into String pool explicitly. its only when you create String object as String literal e.g. String s = "Test" it put the String in pool.
Similar topics
» String Matching
» String Matching KMP
» Permutations of a String
» Reverse a String
» Reverse words in a string
» String Matching KMP
» Permutations of a String
» Reverse a String
» Reverse words in a string
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum