File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes String initialization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "String initialization" Watch "String initialization" New topic

String initialization

Satish Kota
Ranch Hand

Joined: Feb 08, 2006
Posts: 88
Which method of String class is called when a String object is being initialised or assigned. This is what i meant:

String s= "abc";

Which method of String class gets invoked to check for for existing value in string pool during this assignment process

SCJP 5.0 77%
Sanjeev Singh
Ranch Hand

Joined: Nov 01, 2006
Posts: 381
I don't think any method is called it all depends on underlying JVM implementations.(esp String pool).

~Sanjeev Singh<br />SCJP 1.5
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

This is largely an implementation detail. It's clearly not the single argument contructor that assigns a unique memory space.

I chalk it up to Java vodoo, but who knows.

-Cameron McKenzie
I agree. Here's the link:
subject: String initialization
It's not a secret anymore!