Results 1 to 6 of 6

Thread: Hashmap

  1. #1
    dirtycash is offline Member
    Join Date
    Nov 2007
    Posts
    38
    Rep Power
    0

    Default Hashmap

    ...........................
    Last edited by dirtycash; 12-09-2007 at 11:11 PM. Reason: missed something out

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    Java Code:
    public class Cashier
    {
        // the key will be a String value which 
        // is the email address of the account.
        // The value will be the Account object itself.
        HashMap<String, Account> accounts;
    
        Cashier()
        {
            accounts = new HashMap<String, Account>();
        }
    }

  3. #3
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    cannot find symbol - class HashMap
    import java.util.HashMap;

  4. #4
    dirtycash is offline Member
    Join Date
    Nov 2007
    Posts
    38
    Rep Power
    0

    Default

    import java.util.HashMap; - this has to go at the beginning of the code?
    could you tell me what it does?


    and what should this look like?

    You need to write a single constructor for Cashier which initialises the field to an empty
    HashMap

  5. #5
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    this has to go at the beginning of the code?
    Yes.
    could you tell me what it does?
    It tells the jvm where to look for the definition of the HashMap class.
    and what should this look like?
    Like this:
    Java Code:
        Cashier()
        {
            accounts = new HashMap<String, Account>();
        }

  6. #6
    dirtycash is offline Member
    Join Date
    Nov 2007
    Posts
    38
    Rep Power
    0

Similar Threads

  1. HashTable vs HashMap
    By bugger in forum New To Java
    Replies: 7
    Last Post: 01-06-2011, 04:15 PM
  2. ArrayList into hashMap
    By Preethi in forum New To Java
    Replies: 2
    Last Post: 02-11-2008, 09:13 AM
  3. HashMap with objects
    By otoro_java in forum New To Java
    Replies: 2
    Last Post: 01-28-2008, 04:28 PM
  4. HashMap visual example
    By jhetfield18 in forum Advanced Java
    Replies: 1
    Last Post: 12-12-2007, 08:45 PM
  5. what is hashmap
    By gabriel in forum New To Java
    Replies: 5
    Last Post: 08-03-2007, 02:23 PM

Posting Permissions

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