What is the difference between String str = new String("SOME") and String str="SOME"
Does these declarations gives performance variation.
What is the difference between String str = new String(SOME) and String str=SOME Does
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
always create a new object on the heap
uses the String pool
Try this small example:
To avoid creating unnecesary objects on the heap use the second form.