Sorry, but I'm not that good at english, I'll try to answer your 2nd question, but I'm not sure I understood it well !
Originally posted by Maureen Charlton:
"Firstly, what does the exception in thread "main" java.lang.Stack mean? Is it to do with recursion i.e. including the class Student and main TestStudent together is not such a good idea? (Arnald Burlet - thanks for your input here).
That exception means you eated all the available RAM. (see below)
It has to do with recursion yes, but "including the class Student and main TestStudent together" is not the problem, that's normal use. Your problem is INFINITE recursion! Let me explain that quickly.
Whenever you call a function - like System.out.println() or Student.put() - you need some memory on the stack to save informations. The stack is a special zone of memory, a part of your RAM. Each function call needs some space on the stack and if a function call can't obtain the needed space on the stack, you get a java.lang.StackOverflow exception (the one you got running your program).
Now, how is it your program eated all the stack space ? This is because you call infinitely Student.put() (remember each call need some space on the stack), so after some number of function calls, your stack gets full and you get the exception!
got it ?
Originally posted by Maureen Charlton:
Secondly, with a dynamic array you use a loop to implement the array reference for the data i.e. Name would be Name [0][0 ] the first name and Course would be [0][1] but I'm not so sure I have implemented this for a HashMap i.e. as Name is my Key and Course is my value surely I do not need a loop to increment anything in the hashmap; and if I did is my understanding correct when I think I have to use the Set i.e. Set keys = map.keySet() to get an Iterator and use the iterator to put each of the elements of the set in turn? (A response on this question would be appreciated!)
No, you don't need anything special to put values in a HashMap. The way you do it is perfectly correct.
But I think you have a problem, something like only one name,course in the hashmap ?
If that's the case, check your Student.put() method, your body (after my first correction) should be
And that's where the problem resides ... What are you passing to the put() method ? You are not passing the name and course parameters, your are always ordering the hashmap to store the same Strings ! just remove the "" so that your code looks like :
Arnaud
[edit : ubb hates me today, polishing]
[ October 15, 2004: Message edited by: Arnaud Burlet ]