How to make and iterate through a HashMap with an ArrayList in it

public class MailServer
// Storage for the arbitrary number of mail items to be stored
// on the server.
private ArrayList <MailItem> items;
private HashMap <String, ArrayList<MailItem>> mapper;
* Construct a mail server.
public MailServer()
items = new ArrayList<MailItem>();
mapper = new HashMap<String, ArrayList<MailItem>>();
a MailItem is a class that has objects to: from: message: subject
if I add
mapper.put("bob", mailItem1);
mapper.put("jo", mailItem2);
mapper.put("bob", mailItem3);
how can I go through the hashmap and display all the messages that there are for each person? (mailItem has a print() method that prints out the email info.
thanks all, i'm a newbie

If your map's values are lists, you have to append to that list, and create it the first time, too.
Demo:
import java.util.*;
public class MapExample2 {
    private Map < String, List < Integer > > map = new HashMap < String, List < Integer > > ();
    public void append(String key, Integer valueElement) {
        List < Integer > list = map.get(key);
        if (list == null)
            map.put(key, list = new ArrayList < Integer > ());
        list.add(valueElement);
    public String toString() {
        return map.toString();
    public static void main(String[] args) {
        MapExample2 app = new MapExample2();
        app.append("even", 10);
        app.append("even", 20);
        app.append("odd", 17);
        app.append("even", 30);
        app.append("odd", 11);
        app.append("odd", 43);
        System.out.println(app);
}

Similar Messages

  • TS1702 I cannot get an unlocked version of drivesafe.ly to operate on any accounts on my iphone 4S and have had no help when I asked them for support.  I am now trying to figure out how to refund the product.  Anyone know how to make that request through

    I cannot get an unlocked version of drivesafe.ly to operate on any accounts on my iphone 4S and have had no help when I asked them for support.  I am now trying to figure out how to refund the product.  Anyone know how to make that request through itunes?

    Try assigning Queen as the Album Artist on the compilations in iTunes on your computer.

  • How to make and Burn the project to DVD

    Would you pleased advice me how to make and burn the Project to a DVD as I'm new user for the Adobe Premier Pro.
    Tks & B/regards,
    Handjojo

    As said before you need Adobe ENCORE to make dvd menu and burn to dvd.
    But first you need to download and install Adobe ENCORE.
    Follow the instrtuctions in the link below how do downlaod and install.
    Encore CS6 not installed with Creative Cloud
    Then go over to Adobe TV.
    How to make a DVD.
    AdobeTV Learn Encore CS4 
    Learn Encore CS5 | Adobe TV 
    Using Premiere Pro CC & Encore CS6 for Bluray, DVD, and Interactive Video for iPad,ATV, and Mobile HD | DAVTechTable | Adobe TV 

  • Has anyone figured out how to make the Yamaha 01V96i mixer work with Logic 9.1.8

    Has anyone figured out how to make the Yamaha 01V96i mixer work with Logic 9.1.8 as a control surface ?

    In YAMAHA01v96i:
    Go to DIO/SETUP select Generic DAW. Go to MIDI settings page and set the desired port (personally I use Number 1), Select the same audio frequency you use in your DAW (I use 44.1KhZ)...at this point You should save a scene in you 01V96i to avoid to repeat all the procedure again.
    Open studio manager, go to patch and set the input port from 17 to 32 respectively to USB1-USB16 (this will give you the return from you DAW to the 01v96i
    Save again the scene overwriting the old one.
    in LOGIC
    Click on preferences, select Audio then select 01v96i, then click on control surface and select Mackie design Baby HUI and in the midi session set the same port that you've been setting on the Yamaha 01V96i (Port 1 if you follow this example).
    That's more or less it.
    It worked for me...so far

  • Hello guys..does anybody know how to install and use adobe master collection with the new lion?   I need to use Flash and illustratore, but apparently those programmes are incompatible with the new operative sistem...   I am a new mac users and I'd like t

    Hello guys..does anybody know how to install and use adobe master collection with the new lion?
    I need to use Flash and illustratore, but apparently those programmes are incompatible with the new operative sistem...
    I am a new mac users and I'd like to know if there are other similar programmes I can use with lion!

    Lab79 wrote:
    Are you on Apple's payroll?
    well dude I can only let you know that as I work with those programme I don't have to pay for it is my company that pays the programme I whant to use( that's why I was asking if there where other programmes ..that I could use with lion insted that Illustrator and Flash!)..I know Adobe since 2005 and I can say that Adobs products are very good...I think that if it's an Adobe probleme or fault ..they will solve it very soon...but unfortunally I have the impression that after Jobs passed away Appel decided to change politics..and everything started to go very bad! (see FCP X)..
    good luck with apple dude..
    Where is the Apple problem? I have CS4 and CS5 running perfectly fine on my Macbook Pro. Installed 5 after Lion upgrade. Worth every cent. Adobe did have some catching up to do with Lion but with the CS5.5 update all runs fine. But not yours. So it is a problem with the Lion OS? You say you have been with Adobe since 2005. So you would be aware of all the other issues that Adobe had catching up with past Oss in Mac and Windows then. They get it right, but it is up to them. It is not up to Apple, nor Microsoft for that matter, to run around and check that every software developer in the world is running their business properly.
    And what has politics got to do with anything. Some people just have to blame Software for their poor Hardware maintainence of failure of the same.
    <The only think I can really do is to go back on my old windows...give back this orrible lap top and ask for my money back!>
    Great suggestion. You should go with that one, but good luck getting a refund.
    Bye

  • Just found Ipad Nano in Big Island Hawaii. Trying to find the owner to return it back. Tell me what is the color, how many songs and your name(its personalize with a name).

    Just found Ipad Nano in Big Island Hawaii. Trying to find the owner to return it back. Tell me what is the color, how many songs and your name(its personalize with a name).

    I only wish that when I called Apple, they would match the serial number with the owner and give me the contact
    Hopefully you left Apple your contact info (name phone #, email address).
    Apple would simply pass your contact to the last registered owner. It would be up to the owner to contact you. As Dave mentioned, Apple will not give you any info (except may to tell you it was or was not registered, but not to who). Turn it on once in a while and maybe they have activated FindMyiPad and a message will pop up (don't need to be logged onto the iPad to a message).

  • Can anyone explain how to download and upload TROY ECF fonts with SAP

    Can anyone explain how to download and upload TROY ECF fonts with SAP.I have downloaded ECF font from TROY wesite as TTF format. but it is not getting upload with SAP.please kindly help me on this issue..

    Hi,
    You can use the SE73 Transaction and upload your TTF files.
    Please check the link here for more details:
    http://help.sap.com/saphelp_nw70/helpdata/en/36/5b3438fd263402e10000009b38f8cf/frameset.htm
    Regards,
    Siddhesh

  • How to download and upload TROY ECF fonts with SAP for check printing

    Can anyone explain how to download and upload TROY ECF fonts with SAP.I have downloaded  ECF font from TROY wesite as TTF format. but it is not getting upload with SAP.please kindly help me on this issue..

    Hi,
    You can use the SE73 Transaction and upload your TTF files.
    Please check the link here for more details:
    http://help.sap.com/saphelp_nw70/helpdata/en/36/5b3438fd263402e10000009b38f8cf/frameset.htm
    Regards,
    Siddhesh

  • How to split a string into tokens and iterate through the tokens

    Guys,
    I want to split a string like 'Value1#Value2' using the delimiter #.
    I want the tokens to be populated in a array-like (or any other convenient structure) so that I can iterate through them in a stored procedure. (and not just print them out)
    I got a function on this link,
    http://www.orafaq.com/forum/t/11692/0/
    which returns a VARRAY. Can anybody help me how to iterate over the VARRAY, or suggest a different alternative to the split please ?
    Thanks.

    RTFM: http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/collections.htm#sthref1146
    or
    http://www.oracle-base.com/articles/8i/Collections8i.php

  • How to make and use distribution list?

    How do I make and use a distrubition list in mail?
    I know how to do it on a PC but cannot find it on the MAC?

    You create a Group in AddressBook.

  • How to make boot disk for MacBook Pro with Mavericks pre-installed

    Hi -
    I recently bought a new 15" MacBook Pro with Retina Display, which came pre-installed with Mavericks (10.9.0).  I want to make a bootable USB disk of the system software, and have successfly used DiskMaker X (formerly Lion DiskMaker) to make the USB boot disks for Lion and Mountain Lion.  In those cases, however, I was running earlier versions of the OSX, and downloaded the new OSX version -- Lion and Mountain Lion -- from the App Store in order to make to make the disk.  In this case, however, Mavericks was pre-installed, and I was unable to download it from the App Store (an alert said that it couldn't be installed on this computer... presumably because it was already installed).  I would apprecite any suggestions as to how I can create the boot disk without the ability to download Mavericks.  Thanks very much for any help anyone can provide.
    Shelly

    Open App Store and locate the full installer download file (5.29 GBs) for 10.9.1. Download to your computer.
    Make Your Own Mavericks, Mountain/Lion Installer
    After downloading the installer you must first save the Install Mac OS X application. After the installer downloads DO NOT click on the Install button. Go to your Applications folder and make a copy of the installer. Move the copy into your Downloads folder. Now you can click on the Install button. You must do this because the installer deletes itself automatically when it finishes installing.
        2. Get a USB flash drive that is at least 8 GBs. Prep this flash drive as follows:
    Open Disk Utility in your Utilities folder.
    After DU loads select your flash drive (this is the entry with the mfgr.'s ID and size) from the leftside list. Under the Volume Scheme heading set the number of partitions from the drop down menu to one. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, set the partition scheme to GUID then click on the OK button. Click on the Partition button and wait until the process has completed.
    Select the volume you just created (this is the sub-entry under the drive entry) from the left side list.
    Click on the Erase tab in the DU main window.
    Set the format type to Mac OS Extended (Journaled.) Click on the Options button, check the button for Zero Data and click on OK to return to the Erase window.
    Click on the Erase button. The format process can take up to an hour depending upon the flash drive size.
        3. Use DiskMaker X to put your installer clone onto the USB flash drive.
    Make your own Mavericks flash drive installer using the Mavericks tool:
    You can also create a Mavericks flash drive installer via the Terminal. Mavericks has its own built-in installer maker you use via the Terminal:
    You will need a freshly partitioned and formatted USB flash drive with at least 8GBs. Leave the name of the flash drive at the system default, "Untitled." Do not change this name. Open the Terminal in the Utilities folder. Copy this command line after the prompt in the Terminal's window:
    sudo /Applications/Install\ OS\ X\ Mavericks.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath /Applications/Install\ OS\ X\ Mavericks.app --nointeraction
    Press RETURN. Enter your admin password when prompted. It will not be echoed to the screen so be careful to enter it correctly. Press RETURN, again.
    Wait for the process to complete which will take quite some time.

  • HT2801 How to make external "SuperDrive" work on iMac with failed built-in?

    WHY is my new external "SuperDrive" "designed exclusively for use with Mac computers that do not have a built-in optical drive"?  How can I make it work on my iMac with a failed built-in "SuperDrive" that was obviously junk to begin with?  I ordered it from a Staples kiosk that had zero product information but the name of the product was USB SuperDrive and it was made by Apple so I reasoned it would run on my Apple.  I bought an LG 2 months ago when the built-in failed but the LG only worked about a month then every disc burn was aborted as "error."  So I bought new burn software from the Apple app store but still "error" so I went to Staples and bought this and it didn't work so I ise a magnifying glass to read the light grey letters on the white box and it says "Compatible with Mac systems without a built-in optical drive."  I found articles online advising how to hack my own computer to make this work but I am low-tech and afraid of wrecking my computer.  I am FURIOUS with Apple, I buy it only because Windows gave me such grief but honestly Apple hardware has OFTEN proven itself short-lived and low quality.  PLEASE how do I burn an audio CD with my stupid iMac peice of garbage?

    Calm down.
    If you so choose here are some quality optical drives you can purchase, online here.
    http://eshop.macsales.com/item/OWC/VLU2SD24XS/
    http://eshop.macsales.com/item/OWC/MR3F82SD24S/
    For Mac burning software, you can purchase and use Roxio Toast.
    http://www.roxio.com/
    OR you can try this freeware software called simply Burn.
    http://burn-osx.sourceforge.net/Pages/English/home.html

  • How to make the Printer deskjet 3940 compatible with Windows 7, home basic, 32 bits?

    I have HP Deskjet 3940 Printer. I recently purchased a Lenovo desktop( C320, 57-302429) which has Windows 7,home basic,32 bits operating system. The said printer does not work with the above computer. Please guide how to make this printer compatible with the above operating system.
    This question was solved.
    View Solution.

    1. Click the Start button, click Control Panel and double click Devices and Printers.
    2. Click Add a Printer.
    3. Select Add a local printer.
    4. Choose an existing USBx Local port, click Next.
    5. Click the Windows Update button.
    6. After the update finishes, search for the 3940 driver.
    7. click Next,Next,Next,Next,Finish
    Please mark the post that solves your issue as "Accept as Solution".
    If my answer was helpful click the “Thumbs Up" on the left to say “Thanks”!
    I am not a HP employee.

  • How to make the active save-to-file with the data from GPIB ?

    Hello,,everybody !!
    I want to make the active save-to-file with the data from GPIB since starting the measurement. To save-to-file at the end of measurment is somehow risky for losing the data because my measurment have to take for long time (eg. 24-48 hours).
    Thank you in advance for anybody's help !!

    Thanks Dennis,
    I have already append, I got it but still have one small problem that between each line it has the blank line. Example as below ,
    16:40:33 54.24
    16:40:34 54.23
    16:40:35 54.24
    I want to get rid of the blank line in between.. Do you have the idea about it ?

  • How to make an animation(dancing doll) sync  with the music of a song?

    I have a small animation that contains a doll, that need to be synchronized(doll should dance) with the song that is being played at the background. The song is loaded dynamically and the it should shake according to the music.

    Hi kglad,
        Thanks for your reply!! The issue here is, animation need to be
    synchronized with a wide range of songs, so i am looking for a solution
    which detects the tempo of the song that is being played and doll to be
    synchronized with it....
    Thanks in advance!!!

Maybe you are looking for