Dear Programmers,
Forgive my lack of knowledge regarding correct programming for API collections Hash Map, but I can't quite get it right, as I wanted program to submit the placed Strings - including the ISBN numbers, yet as coded, program only submits the authors, I can't get it to give the ISBNs - is it that next() method thats forcing it to skip alternating strings - and/or can I put in another method that will output the ISBN strings as stored ?
The output order is as Exercise stipulates - so its half right, I suppose.
[CODE]
import java.util.*;
public class MyMap
{
public static void main(
String [] args)
{
Map myHashMap = new HashMap();
myHashMap.put("James Joyce", "111-12-1212");
myHashMap.put("Mai Li", "222-21-2121");
myHashMap.put("Murray Kaye", "333-31-1313");
myHashMap.put("Sam Adams", "444-41-4141");
myHashMap.put("Juanita Perez", "555-51-1515");
// Create Iterator and while loop
Iterator myIterator;
myIterator = myHashMap.keySet().iterator();
while (myIterator.hasNext())
{
String myKey;
myKey = (String)myIterator.next();
System.out.println(myKey);
}
}
}
[//CODE]
gives:-
[CODE]
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\user>set PATH=C:\jdk1.42\jdk\bin
C:\Documents and Settings\user>cd C:\lab_files\Lesson_7
C:\lab_files\Lesson_7>javac MyMap.java
C:\lab_files\Lesson_7>
java MyMap
James Joyce
Murray Kaye
Juanita Perez
Mai Li
Sam Adams
[//CODE]
Thank you for your help in advance
Yours
Mary Dawson.