I'm hoping that somebody could look at this code and perhaps give me some pointers or something to think about to improve the efficiency. Ok so I have a map that holds strings and student class objects, from that I get the name of the student and using the score variable test that against the range of conditions, increasing the grade int accordingly then printing out the grade and the integer grade total. Like I said this works well enough but does anybody have any pointers that they could give me to think about to improve the efficiency. Please no Iterators I don't want to use one.
Joined: Oct 13, 2005
Welcome to JavaRanch
As you say, it works, and it looks nice code.
I presume you are using the Map elsewhere with get(name) and put(name, Student)?
Can you use the values() method of your Map to get a Collection<Student> and iterate through that with the for-each loop? It will probably only improve prformance slightly because hashing and finding values from a Map is usually a fast operation.
You are in fact using an Iterator; there is an Iterator which hides behind the for-each loop.