Hello, I am trying to convert a String field to a Short type and cast desn't seem to work. Any advice willbe useful. My code is as follows-- String sParmValue = ""; short len = 0; short csrposn = 0; . . . . }else if (sParmName.equals("c__Scrn__Cposn_I")) { LL350C.setC__Scrn__Cposn_I(sParmValue); } Now, I the setC__Scrn__Cposn variables of Short type and sParmValue is a String. SO how can I convert sParmValue to type Short so that I can assing it to C__Scrn__Cposn__I. Thanks!! Veni.
Short.parseShort(sParmValue) should do this. HTH, - Manish
Dave Vick
Ranch Hand
Joined: May 10, 2001
Posts: 3244
posted
0
Veni What you want is the parseShort metod in the Short class. It takes a String and returns a short. You have to put it in a try/catch block to catch the possible NumberFormatException it can throw. something like is what you want:
hope that helps
------------------ Dave Sun Certified Programmer for the Java� 2 Platform