Results 1 to 5 of 5
Like Tree2Likes
  • 1 Post By Tolls
  • 1 Post By DarrylBurke

Thread: What is the Default value for a String object?

  1. #1
    mkarthik90 is offline Member
    Join Date
    Feb 2012
    Posts
    62
    Rep Power
    0

    Default What is the Default value for a String object?

    The default value of the integer is 0 . Similarly can anyone tell me what is the default value for String ?

  2. #2
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,089
    Rep Power
    20

    Default Re: What is the Default value for a String object?

    Same as any other Object.

    If it's a local variable it is undefined.
    If it's an attribute then it's null.
    DarrylBurke likes this.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,408
    Rep Power
    20

    Default Re: What is the Default value for a String object?

    Just to correct the terminology: objects don't have default values. References, or variables, do.

    db
    Tolls likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    mkarthik90 is offline Member
    Join Date
    Feb 2012
    Posts
    62
    Rep Power
    0

    Default Re: What is the Default value for a String object?

    i used the following code.

    String[] col = new String[20];

    for example say i stored only 10 objects in the array how to iterate only the 10 objects ? Is there any inbulit function avaiable.

    for(i=0;what condition to be used;i++)
    {

    }

  5. #5
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,089
    Rep Power
    20

    Default Re: What is the Default value for a String object?

    In the case of arrays, the references (thanks for the correction Darryl) to Objects are null, so just check for null as well as 'i < col.length'.

Similar Threads

  1. Replies: 1
    Last Post: 01-09-2012, 04:46 PM
  2. Casting a String object to a Form object
    By kakinyim in forum CLDC and MIDP
    Replies: 0
    Last Post: 04-23-2011, 11:41 AM
  3. Default value of String upon construction
    By Return 0 in forum New To Java
    Replies: 5
    Last Post: 03-03-2011, 09:01 PM
  4. Prevent default write object serialization
    By nwboy74 in forum Advanced Java
    Replies: 5
    Last Post: 06-10-2010, 10:30 PM
  5. Replies: 1
    Last Post: 03-10-2009, 01:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •