Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

1).what is the difference between below examples

String s="vijay";

String s=new String("vijay");

Answer Posted / vijay

yes karun and ravi u both are right...!!
dear friends there is small difference b/w both string
declaration but both have create huge differences.

String s="vijay"; // string literal
that means it create one object and one reference and object
will be created in string pool.

String s= new String("vijay"); //string object
that means it create two object and one reference and one
object will be created in string pool and another on heap.

and difference what ravi want to say is ....if

String s="vijay";
String s1="vijay";
means here s and s1 both refer the same object whereas

String s=new String("vijay");
String s1=new String("vijay");
here these reference s and s1 refer refer 2-different
object.

that is why the first one give the better performance.

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can a constructor call the constructor of parent class?

978


List some java keywords sun like c, c + + keywords?

964


What is keyword auto for?

1106


What is variable explain?

962


What is bitwise complement?

928


When throws keyword is used?

947


Which data type is a class in java?

936


Can a class be private?

915


Which oo concept is achieved by using overloading and overriding?

951


What is the purpose of checked and unchecked exceptions in JAVA?

957


How would you dynamically allocate memory to an array?

994


How do you classify Dialog Box?

1066


What’s a deadlock?

1048


What is a instance variable?

1014


What restrictions are placed on method overriding in java programming?

935