# is this a way to convert String to integer?

is this a way to convert String to integer?

Integer currentStartingPrice = new Integer((String)startingPrice.getText());
int price = currentStartingPrice;

thx
Tom

###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Integer currentStartingPrice = new Integer(startingPrice.getText());
0
Commented:
Or just

int price = Integer.parseInt(startingPrice.getText());

0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Commented:
int       i = Integer.parseInt(s);
long       l = Long.parseLong(s);
float       f = Float.parseFloat(s);
double       d = Double.parseDouble(s);

Convert integers with some base (radix) other than 10 by using these two methods.
if you want to convert numbers in hexadecimal or base 2 ... use

For example, to convert a string containing the hexadecimal number "F7" to an integer, call

i = Integer.parseInt("F7", 16)
0
Commented:
0
Author Commented:
i need to import this

import java.lang.*;
import java.lang.Object.*;

is tat correct?
0
Commented:
No. java.lang.* doesn't need importing
0
Author Commented:
so only import java.lang.Object.*;  ??
0
Commented:
by default/implicitly the java.lang package is available for the JVM
0
Commented:
>>so only import java.lang.Object.*;  ??

Dont import anything in lang
0
Author Commented:
i did some silly mistake..

thxx
0
Commented:
Can you tell me why you accepted an answer that merely repeats the one i'd already given?
0
Author Commented:
i accidentally press the wrong button though..

i just kinda hurry when i clicked. and i don't know how to cancle that :(
0
Commented:
>>and i don't know how to cancle that :(

By reopening the question ;-) i'll get it done
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.