Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

string vs new string

String str = new String("");
String str2 = "";

They both immutable and they save in different 
memory location. String objects created without
the use of new keyword are stored in the
String Constant Pool part of the heap.
It doesn't create the same string object
if there is already string constant in the pool.
Comment

PREVIOUS NEXT
Code Example
Java :: java dictionary initialization 
Java :: Java long Keyword 
Java :: exception class implementation in java 
Java :: java scanner next() 
Java :: java delete element from list 
Java :: Alerter for java 
Java :: mongorepository spring boot custom query 
Java :: json java 
Java :: random value between 10-20 
Java :: syntax of the switch statement in Java 
Java :: lambda expression java 
Java :: what is construct in java 
Java :: multiple inheritance in java 
Java :: binary tree traversal 
Java :: android studio convert java to kotlin 
Java :: switch java 
Java :: android hide and show bottom navigation 
Java :: singleton 
Java :: how to divide a double in java 
Java :: string cannot be resolved to a type eclipse 
Java :: join strings in java 
Java :: String to java.sql.Date 
Java :: @Async how it works @EnableAsync 
Java :: h2 database spring boot create table application.properties 
Java :: generate random color java 
Java :: add image in loggin view spring boot security 
Java :: clor text consol java 
Java :: android java convert boolean to string 
Java :: trémaux’ methode 
Java :: Start Text from top left android 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =