Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: String

  1. #1
    Banned
    Join Date
    Feb 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    String

    what is the difference between null value and empty string?

  • #2
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    main difference

    Very big!

    Empty String is an OBJECT of type: String (new String()

    )
    It means there is an object associated to variable and you can call object methods:
    String s = new String(); //object initialization (empty string)
    System out println( s.length() );


    NULL String means that there is no reference to any OBJECT.
    String s;
    System.out.println( s.length() ); //this will throw NullPointerException

  • #3
    Regular Coder
    Join Date
    Jan 2009
    Location
    india
    Posts
    145
    Thanks
    0
    Thanked 5 Times in 5 Posts
    Follow Posting guidelines for better response


  •  

    Posting Permissions

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