|
|
Re: Converting an object to String and then to int
|
Posted: May 23, 2005 1:29 AM
|
|
> I need help in calling method xxx.getValueSelected that > returns anobject from a JList , then convert it to a > string, and then to an int,prior to storing it my declacre > (int) number. > > I am very new to Java.
[code] String myString = xxx.getSelectedValue().toString(); // next method will fail if selected item does not // have an int format. getIndex returns index. // if you want an int value of the selected String // this is what you do. Not the previously suggested int myInt = Integer.parseInt(myString); [/code]
|
|