aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes static strings Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "static strings" Watch "static strings" New topic
Author

static strings

Chris Meijers
Greenhorn

Joined: Nov 07, 2000
Posts: 9
Took the exam this morning and passed with 77%. Good exam, but it made me wonder about a few things. When a class contains a static string member, I thought it was automatically initialized to "". So I could use it in an instance method (to print it for example). But now I am not so sure anymore. Any clarification?
Oliver Grass
Ranch Hand

Joined: Nov 02, 2000
Posts: 65
Hi Chris,
congrats for the 77%. Not bad... :-))
Originally posted by Chris Meijers:
When a class contains a static string member, I thought it was automatically initialized to "". So I could use it in an instance method (to print it for example). But now I am not so sure anymore. Any clarification?

Nope, that's not right...
String is an Object, and object will always be initialized with null.

You will get s = null as output.
Hope that clarifies a bit, correct me if i'm wrong
Oliver
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: static strings
 
Similar Threads
static blocks relevant for SCJP 1.4
Initializer, 1.4, 1.5 or both
Static Methods Overriding
a doubt
No static variable within a non-static method?