plz plz help me(urgently required) how to get an integer from a text field
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   kumar_john
Posted On:   Wednesday, June 27, 2007 11:00 AM

How can i get an integer from a textfield



i done it following maner but it didn't work



int x = Integer.parseInt(t1.getText());



it shows an error like this:


java.lang.NumberFormatException: For input string: " 235454"



plz plz help me what i will do ???

Re: plz plz help me(urgently required) how to get an integer from a text field

Posted By:   David_Thornton  
Posted On:   Wednesday, June 27, 2007 08:06 PM

It looks like you have leading white space which is causing the NumberFormatException. Try adding trim();



int x = Integer.parseInt(t1.getText().trim());

About | Sitemap | Contact