×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    25

    Question How Can Check Int Is Null?

    Hi.
    i use this code:
    if(UqNo.UqNoRecordResult == null)
    {//something
    }

    but it error:
    operator == cannot be applied to int,<nulltype>
    if(UqNo.UqNoRecordResult == null)

    because:
    ints cant be null, int is a primitive data type, only reference types can have null values.

    so why its say UqNoRecordResult is null and error happen in runtime?!
    i Share,U Share,V Learn

  2. #2
    Registered User
    Join Date
    Sep 2007
    Location
    Bangalore
    Posts
    868

    Re: How Can Check Int Is Null?

    Hi dr_jacky,

    What ever you are saying is correct . What is the class definition of the UqNo ? Can you post this class .

  3. #3
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: How Can Check Int Is Null?

    Quote Originally Posted by dr_jacky_2005 View Post

    because:
    ints cant be null, int is a primitive data type, only reference types can have null values.

    so why its say UqNoRecordResult is null and error happen in runtime?!
    What is the exactly eror message you are getting?
    what exactly UqNo is?
    is this a class or the instance, if instance then check if it is null,
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  4. #4
    Registered User
    Join Date
    Feb 2011
    Posts
    25

    Re: How Can Check Int Is Null?

    Quote Originally Posted by raj_J2ME View Post
    What is the exactly eror message you are getting?
    what exactly UqNo is?
    is this a class or the instance, if instance then check if it is null,
    UqNo is instance of UqNo class.
    ____
    for your first Q:
    if(UqNo.UqNoRecordResult == null)
    {//something
    }

    but REAL error:
    operator == cannot be applied to int,<nulltype>
    if(UqNo.UqNoRecordResult == null)
    _______
    i Share,U Share,V Learn

  5. #5
    Registered User
    Join Date
    Sep 2007
    Location
    Bangalore
    Posts
    868

    Re: How Can Check Int Is Null?

    Hi ,

    If you print the value of the UqNo.UqNoRecordResult what are you getting . Can you post that class ?

  6. #6
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: How Can Check Int Is Null?

    I would guess that UqNo is null...

    Graham.

  7. #7
    Registered User
    Join Date
    Feb 2011
    Posts
    25

    Re: How Can Check Int Is Null?

    Quote Originally Posted by grahamhughes View Post
    I would guess that UqNo is null...

    Graham.
    how can be null ! when i get instance form UqNo Class!?
    i Share,U Share,V Learn

  8. #8
    Registered User
    Join Date
    Sep 2007
    Location
    Bangalore
    Posts
    868

    Re: How Can Check Int Is Null?

    Hi dr_jacky_2005 ,

    The UqNoRecordResult is an integer you did a mistake by comparing with the null type . Are you getting this exception at compile time or runtime ? This declaration could be compile time error only.
    if(UqNo.UqNoRecordResult == null)
    {//something
    }

  9. #9
    Registered User
    Join Date
    Feb 2011
    Posts
    25

    Question Re: How Can Check Int Is Null?

    Quote Originally Posted by bhanuchandar.k View Post
    Hi dr_jacky_2005 ,

    The UqNoRecordResult is an integer you did a mistake by comparing with the null type . Are you getting this exception at compile time or runtime ? This declaration could be compile time error only.
    its compile error.

    so how can is check this integer variable?!
    i Share,U Share,V Learn

  10. #10
    Registered User
    Join Date
    Sep 2007
    Location
    Bangalore
    Posts
    868

    Re: How Can Check Int Is Null?

    Hi dr_jacky_2005 ,

    By default the integer variables are assigned to 0 you can check for zero
    if(UqNo.UqNoRecordResult == 0)
    {//something
    }

  11. #11
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: How Can Check Int Is Null?

    ints are never null. If you are getting a NullPointerException, then it is not because of the int.

    Did you check that UqNo is not null?

    Graham.

Similar Threads

  1. How can I check a file is txt or binary type?
    By GFYsweetwood in forum Symbian
    Replies: 3
    Last Post: 2009-08-25, 11:19
  2. How can check a directory is already exist?
    By GFYsweetwood in forum Symbian
    Replies: 4
    Last Post: 2008-10-28, 09:59
  3. how can I check that a socket is connected?
    By tonmoy_symbian in forum Symbian Networking & Messaging (Closed)
    Replies: 5
    Last Post: 2006-09-30, 09:49
  4. How can check that GPRS is activated?
    By ramis55 in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2005-04-11, 15:23
  5. How can check that GPRS is activated?
    By ramis55 in forum Symbian
    Replies: 0
    Last Post: 2005-04-11, 15:21

Posting Permissions

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