This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes default String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "default String" Watch "default String" New topic

default String

sura watthana
Ranch Hand

Joined: Sep 13, 2004
Posts: 77
I'm have a few questions. Could somebody help me out?
is String a class?
will the default String field be empty string("") if the String field has not been initialized?


natarajan raman

Joined: Apr 10, 2004
Posts: 26
Hi Sura,

Yeah String is a class........And about the other question why don't you try and write a small code and get it run....

String n;
String x = new String("");

Such codes will help you.....Any small doubts can be clarified by writing programs....Many of our peers have suggested this. This will help you to learn more definitely.

Still if you face problems then come up with post.....okay....Have good time with Strings....

nata.r<br />**********************************<br />To win is not always success<br />And to lose is not always failure.<br />**********************************
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
You have read the String API?

String s; defines a reference to an instance of the String class.

Except for local variables the default value of object references is null.

The use of the constructor String() (with no arguments) will cause an empty string ("") to be created.

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Don't get me started about those stupid light bulbs.
subject: default String
Similar Threads
Answers of Sun's Free Proficiency Assessment
Please Help, need clarification about K&B book Self-Test Questions
EntityBean and default value of a not null field
Question about @Resource annotation
JSF validation errors