Thread: Autoboxing

Results 1 to 5 of 5
  1. #1 Autoboxing 
    Banned

    Join Date
    Jul 2008
    Age
    26
    Posts
    5,826
    Thanks given
    1,301
    Thanks received
    197
    Rep Power
    0
    What are your opinions on it? I found it quite annoying when i was working with a hash map returning an int, and the int was throwing a null pointer exception, even though it wasn't an object and wasn't null Also, you could be doing it without realizing it. There should be a warning for it lmao.
    Reply With Quote  
     

  2. #2  
    Renown Programmer
    Join Date
    Dec 2008
    Posts
    363
    Thanks given
    1
    Thanks received
    28
    Rep Power
    74
    Quote Originally Posted by Java` View Post
    What are your opinions on it? I found it quite annoying when i was working with a hash map returning an int, and the int was throwing a null pointer exception, even though it wasn't an object and wasn't null Also, you could be doing it without realizing it. There should be a warning for it lmao.
    An int doesn't implement the hashCode() method... because it's not an object...
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  3. #3  
    Banned

    Join Date
    Jul 2008
    Age
    26
    Posts
    5,826
    Thanks given
    1,301
    Thanks received
    197
    Rep Power
    0
    Quote Originally Posted by Parabolika View Post
    An int doesn't implement the hashCode() method... because it's not an object...
    I was using something like this:
    int i = map<String, Integer>.get(key);
    and i diddnt realize it was autoboxing.
    Reply With Quote  
     

  4. #4  
    I_-_I
    Guest
    Quote Originally Posted by Java` View Post
    What are your opinions on it? I found it quite annoying when i was working with a hash map returning an int, and the int was throwing a null pointer exception, even though it wasn't an object and wasn't null Also, you could be doing it without realizing it. There should be a warning for it lmao.
    a primitive value type does not have .hashCode, which the hashmap uses to distribute indicies
    Reply With Quote  
     

  5. #5  
    Banned

    Join Date
    Jul 2008
    Age
    26
    Posts
    5,826
    Thanks given
    1,301
    Thanks received
    197
    Rep Power
    0
    Quote Originally Posted by I_-_I View Post
    a primitive value type does not have .hashCode, which the hashmap uses to distribute indicies
    Google autoboxing.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

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