what is the difference between String s="hello"; and String
s=new String("hello");?
Answer Posted / amit singh
not the difference both are the string
String s = "hello"
its aliteral string it will be in a pool
imagine that when you cretae the anothre string
String s1 = "hello"
thn ther is not new Styrin object wil cretae its will pick
from the pool where the literal strin g hello will presnet
so s>
----------"hello"
s1>
both pointing the same string
2)String s = new String("hello");
there are two string will create frist the litreal "hello"
then the other through the new String("hello"); which is
point through referenece s is pointed so there is always
create a new String which is pointed by the reference s
its not going to pick through the pool
amitsing2008@gmail.com
amit09mca(scjp 1.5 and manymore)
| Is This Answer Correct ? | 3 Yes | 2 No |
Post New Answer View All Answers
What is qms certification?
Explain the key functions of data binding?
What the difference is between execute, execute Query, execute Update?
What is constructor chaining and how is it achieved in java?
What is finalize()?
What is the difference between arraylist and hashset in java?
What is a generic code?
How to make a write-only class in java?
Is math an abstract class in java?
What is size () in java?
What is an infinite loop? How infinite loop is declared?
What is widening and narrowing in java? Discuss with an example.
What are the different ways of implementing thread? Which one is more advantageous?
What's the purpose of using break in each case of switch statement?
how we can use debug in myeclipse 6.0 in order solve the problems that exist in our program when there are 900 to 1000 pages in a web application