Results 1 to 2 of 2

Thread: HashMap errors?

  1. #1
    Join Date
    Mar 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default HashMap errors?

    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:

    Code:
    	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!

  2. #2
    Join Date
    May 2007
    Location
    USA
    Posts
    373
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default

    Haven't tested it, but perhaps:
    Code:
    positions = new Rectangle[]{...};
    What is the error you are getting?

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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •