Thursday, 15 July 2010

typecast list to string using hibernate in java -


I tried to type list data on string, but the error shown as java.lang.ClassCastException: java Can not .lang.String be inserted into Java.util.List please help me solve this problem. This is done using hibernate.

 for  (int i2 = 1; i2 & lt; = gantttablecolnameList.size (+; I2) {columnname = (string) ((list) gantttablecolnameList.get (i1)) Obtain (0); }   

This list contains table column names.

If your list gantttablecolnameList actually string , Then try:

 for  (int i2 = 0; i2 & lt; gantttablecolnameList.size (); i2 ++) {Columnname = (string) (Gentle colnameList.get ( I2)); }   

You are doing this:

  (list) gantttablecolnameList.get (i1)   

Code> list gantttablecolnameList in string , gantttablecolnameList.get (i1) gives you an object which is actually a The string example for the index specified by the runtime value of i1 So, in a nutshell you are trying this:

  (list) "someString";   

Which is impossible.

No comments:

Post a Comment