Is there any chance someone can have a look at this small method and figure out why i'm getting an array-store exception??? I woke up this morning ready to test my AggregateNameFinder2 but i'm getting stupid array exceptions again!!! I am trying to convert an Arraylist <Span> to a Span[] using arrayList.toArray(new Span[0]) as it is suggested in the docs but with no success!!! HOnestly i'm going mental - i've spent 4 hours on this and wherever i look people suggest it is straight forward...

--------------------------------------------------------------------------------------------------------------------------------
    private Span[] flattenUniqueSpans(List<Span[]> findings){

    int maxLength = 0; //the maximum number of predictions

    for (Span[] x : findings)
        maxLength += x.length;

    List<Span> allUnique = new ArrayList<Span>(maxLength);

    for (Span[] k : findings){
    List<Span> temp = new ArrayList<Span>(k.length);

         for (Span s : k)
         temp.add(s);

allUnique.removeAll(temp);//remove from allUnique all the elements that exist in temp allUnique.addAll(temp);//add all elements of temp into allUnique - no duplicates must exist

    }
    ((ArrayList<Span>) allUnique).trimToSize();
      return allUnique.toArray(new Span[0]);

    }
---------------------------------------------------------------------------------------------------------------------------------------

I will be able to provide some feedback for the AggregteNameFinder if this gets sorted...the error obviously occurs in the last line of the method...for some reason there is type mismatch (array-store exception in System.arrayCopy )...Any help is greatly appreciated guys....

Thanks in advance!

Jim

p.s: I'm starting to remember why i left the Java world!!!


Reply via email to