0

Im having problems when trying to initialize the variable:

Map<Sentence, Float>[] vectorValueSentences; // this is ok

/* but this is not */ vectorValueSentences = new HashMap<Sentence, Float>()[100];

I search on what to do but i didnt find any. I read that the object to be initialize has to be static but i dont find a way to declare the Map static.

Thank you for your help!

  • 1
    Can you include a fuller snippet? It's hard to understand without some more context. – Mureinik Oct 10 '15 at 19:21
  • If `vectorValuesSentences` is not declared before calling the line `vectorValueSentences = new HashMap()[100];`, obviously its wrong – sam Oct 10 '15 at 19:22
  • Because of how generics in Java work, you cannot directly create an array of a generic type (such as Map[]). Or You are trying to do something else? More in: http://stackoverflow.com/questions/14917375/cannot-create-generic-array-of-how-to-create-an-array-of-mapstring-obje – Mazeryt Oct 10 '15 at 19:25
  • 2
    You should consider using a List of Maps. List> vectorValueSentences = new ArrayList>(); – Pavan Dittakavi Oct 10 '15 at 19:26
  • Thank you guys! it was my first question here and solve it so quickly. Hope i can help in this community from now on – Ezequiel Santiago Sánchez Oct 10 '15 at 22:58

1 Answers1

1
    HashMap<Sentence, Float>[] vectorValueSentences = new HashMap[100];
deepak marathe
  • 409
  • 3
  • 10