Thread: Maps & HashMaps

Results 1 to 5 of 5
  1. #1 Maps & HashMaps 
    Banned

    Join Date
    Jul 2008
    Posts
    1,043
    Thanks given
    209
    Thanks received
    46
    Rep Power
    0
    what's the main difference between them?

    Code:
    Map<Integer, String> xxx = new HashMap<Integer, String>();
    Code:
    HashMap<Integer, String> xxx = new HashMap<Integer, String>();
    Reply With Quote  
     

  2. #2  
    Registered Member

    Join Date
    Aug 2007
    Posts
    2,395
    Thanks given
    2
    Thanks received
    63
    Rep Power
    558
    they are the same
    but first one is used for convetions i tought
    Reply With Quote  
     

  3. #3  
    Banned

    Join Date
    Jul 2008
    Posts
    1,043
    Thanks given
    209
    Thanks received
    46
    Rep Power
    0
    Quote Originally Posted by Jonas++ View Post
    they are the same
    but first one is used for convetions i tought
    you mean that its the same if I use them but for conventions? lol and why did they make HashMaps and Maps if they are the same?
    Reply With Quote  
     

  4. #4  
    Registered Member

    Join Date
    Aug 2007
    Posts
    2,395
    Thanks given
    2
    Thanks received
    63
    Rep Power
    558
    no, map is interface, which hashmap implements
    i was talking about the formation of it:

    Map<Integer, String> xxx = new HashMap<Integer, String>();
    HashMap<Integer, String> xxx = new HashMap<Integer, String>();
    You should declare it as the first one because this allows you to replace any particular map instance very easily, by changing just one line of code. you should never declare as a implementation eg:
    HashMap<Integer, String> xxx = new HashMap<Integer, String>();
    Reply With Quote  
     

  5. #5  
    Banned

    Join Date
    Jul 2008
    Posts
    1,043
    Thanks given
    209
    Thanks received
    46
    Rep Power
    0
    Quote Originally Posted by Jonas++ View Post
    no, map is interface, which hashmap implements
    i was talking about the formation of it:



    You should declare it as the first one because this allows you to replace any particular map instance very easily, by changing just one line of code. you should never declare as a implementation eg:
    Ok thanks for this
    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
  •