Results 1 to 9 of 9
Thread: Convert String to int
- 06-27-2012, 03:41 PM #1
Member
- Join Date
- Jun 2012
- Posts
- 2
- Rep Power
- 0
Convert String to int
Im also facing the same difficulty..
Im using a textfield to get the values & function say A(int a)
i get values from user by using getText() method.
its getting the textfield content as a string.
i need to pass it to the A(int a).
i cannot parse tat string to int, so it cant be done..
Since im connecting with DB in which the input must be integer, i cant pass the values to that function.
pls help..
- 06-27-2012, 04:04 PM #2
Member
- Join Date
- Jun 2012
- Posts
- 2
- Rep Power
- 0
how to get integer values from jtextfield
Im using a textfield to get the values & function say A(int a)
i get values from user by using textfield.getText() method.
its getting the textfield content as a string.
i need to pass it to the A(int a).
i cannot parse tat string to int, so it cant be passed..
Since im connecting with DB in which the input must be integer, i cant pass the values to that function.
pls help..
- 06-27-2012, 04:06 PM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: Convert String to int
Moving this to its own thread.
Thread's cost nothing, and waking a 2 year old thread is not worth it.
Why can you not parse the String to an int?
That is the only way of taking a String variable and passing it to a method requiring an int parameter.
The rest about the DB makes no sense.
Some code might help clarify what you are trying to do.Please do not ask for code as refusal often offends.
- 06-27-2012, 04:15 PM #4
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,609
- Rep Power
- 5
Re: how to get integer values from jtextfield
See the Integer class and its parseInt method
http://docs.oracle.com/javase/6/docs...g/Integer.html
Edit: I merged the two threads. Please see the forum rules and do not duplicate the same post.Last edited by doWhile; 06-27-2012 at 04:17 PM.
- 06-27-2012, 05:43 PM #5
Senior Member
- Join Date
- Jul 2010
- Posts
- 124
- Rep Power
- 0
Re: Convert String to int
Integer.parseInteger("abc123")
That would return 123
- 06-27-2012, 05:47 PM #6
Re: Convert String to int
@crikey
What nonsense did you just post? Can you explain what that post is supposed to show?If you don't understand my response, don't ignore it, ask a question.
- 06-27-2012, 05:52 PM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: Convert String to int
I'm guessing they didn't try and run that before posting...:)
Please do not ask for code as refusal often offends.
- 06-27-2012, 06:13 PM #8
Re: Convert String to int
Or even compile it. Does run imply compilation?
If you don't understand my response, don't ignore it, ask a question.
- 06-27-2012, 06:23 PM #9
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Similar Threads
-
Dealing with floating-point in double and String and convert it to String
By emad7105 in forum New To JavaReplies: 3Last Post: 02-10-2012, 06:26 PM -
How to convert a string into a BigInteger
By valery in forum New To JavaReplies: 4Last Post: 09-13-2011, 01:32 PM -
Hot to convert string to int ????
By java_no1 in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 06-07-2011, 07:40 AM -
convert string to a date
By exose in forum New To JavaReplies: 10Last Post: 03-14-2011, 12:12 PM -
convert obj to string
By isme in forum New To JavaReplies: 11Last Post: 06-14-2010, 10:54 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks