Results 1 to 2 of 2
  1. #1
    Felissa is offline Member
    Join Date
    Jun 2007
    Posts
    95
    Rep Power
    0

    Default Comparing types, integer with null

    I am looping through an integer array to check to see if it is empty or not but it won't let me compare the arrays values with the term null.

    So what do I do instead?
    Thanks
    Felissa:p

  2. #2
    Eric is offline Senior Member
    Join Date
    Jun 2007
    Posts
    111
    Rep Power
    0

    Default

    Primitive types cannot be null only object references can be compared with null.

    If I recall correctly all int variables are set to zero on declaration. So

    int a[] = { 0, 0, 0, 0, 0 };

    So if 0 is a valid value in your integer array you will probably need to assign it to something else (maybe -1).

    Greetings.
    Eric

Similar Threads

  1. Comparing null problem
    By thirdy_veritech in forum New To Java
    Replies: 2
    Last Post: 02-06-2008, 08:46 AM
  2. Converting data types
    By bluekswing in forum New To Java
    Replies: 4
    Last Post: 01-12-2008, 12:48 AM
  3. Displaying different image types
    By splinter64uk in forum AWT / Swing
    Replies: 1
    Last Post: 12-05-2007, 08:12 AM

Posting Permissions

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