java - Cannot retrieve a Float array from a hashtable -


i limited using legacy collections in java. created hashtable

private hashtable datastock = new hashtable(); 

and 1 of entries of hashtable float array

datastock.put("somearray", new float[24]); 

when want retrieve entry hashtable this:

float[] anotherarray = (float[]) datastock.get("somearray"); 

i following cast exception:

exception in thread "main" java.lang.classcastexception @ java.lang.throwable.fillinstacktrace(<unknown source file>:130) @ java.lang.throwable.<init>(<unknown source file>:51) @ java.lang.exception.<init>(<unknown source file>:13) @ java.lang.runtimeexception.<init>(<unknown source file>:18) @ java.lang.classcastexception.<init>(<unknown source file>:17) @ fr.ecosense.business.flashmemory.restorestockdata(flashmemory.java:297) 

what doing wrong? why storing arrays in hashtable different storing other objects? looking explication there little information on storing arrays in hashtables.

edit: using java me. maybe can cause unexpected behaviour..

just demonstration. piece of code:

    hashtable datastock = new hashtable();     datastock.put("somearray", new float[24]);     float[] anotherarray = (float[]) datastock.get("somearray"); 

works well. means, somewhere in code put datastock other value key somearray type differs float[].


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -