Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: default Value of char

  1. #1
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default default Value of char

    im writing an exercise code, where i need to deal with a character sequence using a char[] array,
    i need to tell the computer to check for a default value of an index of that char[] array


    if (value in the index of this char[] array is default or offset) {

    // do something
    }
    given that , 0 is default of integers, 0.0 for doubles, "" empty string with Strings, how about character?

     char someChar = '',

    if a single quotation is a compile error? a closed character literal, if i put some space, its a white space character..
    how can i assign an offset value for a character variable?


  2. #2
    Super Moderator Sean4u's Avatar
    Join Date
    Jul 2011
    Location
    Tavistock, UK
    Posts
    637
    Thanks
    5
    Thanked 103 Times in 93 Posts

    Default Re: default Value of char

    java primitive default value - Google Search
    Primitive Data Types (The Java™ Tutorials > Learning the Java Language > Language Basics)

    String isn't primitive the default value for a String reference is null - the same as all other references.

    Primitive types only hold valid values. How do you distinguish between valid data of 0 in an int and never-been-assigned? Perhaps you ought to consider using the 'wrapper' classes java.lang.Boolean, java.lang.Character etc?

  3. The Following User Says Thank You to Sean4u For This Useful Post:

    chronoz13 (September 12th, 2011)

  4. #3
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: default Value of char

    String isn't primitive the default value for a String reference is null
    thank you for correcting my statement, objects/references has a 'null' as a default value,

    java.lang.Character
    ahh, so by using a wrapper class's object, i can compare a value between a 'null' and a valid one... thanks thanks

Similar Threads

  1. [SOLVED] How to choose a different toString() Besides the default one?
    By Hallowed in forum Java Theory & Questions
    Replies: 12
    Last Post: April 8th, 2011, 03:05 PM
  2. Default system look and feel does not work
    By goodguy in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 5th, 2011, 11:46 PM
  3. [SOLVED] Class constructor default values
    By srs in forum Java Theory & Questions
    Replies: 3
    Last Post: November 25th, 2010, 09:51 PM
  4. question about default of outFile()
    By odine in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: August 18th, 2010, 12:11 PM
  5. Replies: 5
    Last Post: August 5th, 2010, 09:16 PM