Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Searching for array [] String occurences in hashmap?

Hi all, thanks very much in advance for any pointers!

I have a college assignment and it's confusing me slightly.
I have a hashmap which is basically a timetable for the 3 schools at my college, each school has it's own courses and these courses are prefixed with a specific 3 letter prefix.

For instance, in the School of Computing there is CSN,IMD etc. I have created 3 string arrays, one for each school, containing the various prefixes for each course.

Now I can't seem to find the correct method for searching my hashmap under the conditions of the array lists. The end result is I have to find the percentage of 9 o'clock starts for each school so first I have to find the total amount of events. (Hope this all makes sense! :/)

Here is what I have so far...[code]

static void doStuff(HashMap events){
int soc=0,soc9=0,ebv9=0,ebv=0,acv9=0,acv=0;
String[] SOC={"CSN","IMD","INF","SET","SOC"};
String[] EBV={"BSV","CTR","ELE","MEC"};
String[] ACV={"CLP","DES","JAC","LMD","MUS","SCA"};

for(Event e:events.values())
//for (String s:soc)
if (e.module.substring(0,2).equals(SOC)){

This is an error free run, hence why the foreach is commented out, but still only prints 0?

Sign In or Register to comment.