PDA

View Full Version : HashMap errors?



musi3604
03-02-2009, 03:26 PM
Hey there, I haven't done any Java programming in some years and I'm having a bit of trouble figuring out why my HashMaps are causing syntax errors. Here's what I've got:


Rectangle[] positions = {
new Rectangle(X1,Y2, 50, 400),
new Rectangle(X1+50, Y2, 50, 400),
new Rectangle(X1+100, Y2, 50, 400),
new Rectangle(X1+150,Y2, 50, 400),
new Rectangle(X1+200, Y2, 50, 400),
new Rectangle(X1+250, Y2, 50, 400),
new Rectangle(X1+300,Y2, 50, 400),
new Rectangle(X1+350, Y2, 50, 400),
new Rectangle(X1+400, Y2, 50, 400),
new Rectangle(X1+450,Y2, 50, 400),
new Rectangle(X1+500, Y2, 50, 400),
new Rectangle(X1+550, Y2, 50, 400)
};
HashMap<Rectangle, Integer> midiMap = new HashMap<Rectangle, Integer>();
midiMap.put(positions[1], new Integer(1));

I've also tried midiMap.put(positions[1], 1); and midiMap.put(new Rectangle(positions[1]), new Integer(1)); etc...

Any help would be greatly appreciated!

Trinithis
03-10-2009, 01:08 AM
Haven't tested it, but perhaps:


positions = new Rectangle[]{...};
What is the error you are getting?

or perhaps swap the <K, V> and swap the args in put()