• Post Reply Bookmark Topic Watch Topic
  • New Topic

Defining a map data structure  RSS feed

 
David Freed
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello dear all,
I want to define this data structure , I show you an example

"first street",{{1,40},{43,45},{34,26}},
"second street",{{14,41},{42,5},{3,46}},
............

I wrote in this way but it doesnt work,please write a good one,thanks.

Map<String,ArrayList<int[]>> Street=new HashMap<String, ArrayList<int[2]>>();


 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remove the "2" on the right side. (Note: There is no way to let Java's type system enforce that the array must always have two elements).

Note that if you are using Java 7 or newer you don't have to repeat the type parameters on the right side, you can just use:

 
David Freed
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tnx
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!