Felipe1976
asked on
How to Integer to a string
I Sorry for this quiestion but i dont have idea of how to do this
how can i convert a string to a integer
Felipe
how can i convert a string to a integer
Felipe
int x = Integer.parseInt("12345");
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
int i = 20;
String s = Integer.toString(i);
String s = Integer.toString(i);
objects....
>> convert a string to a integer
String s = Integer.toString(i) ??? Perhaps typed that a little too fast ;-) ?
Anyway, you can also use: int i = new Integer ( stringObject ).intValue (). However, it might be better to use Integer.parseInt ( stringObject ) as it is useless to instantiate an extra object.
>> convert a string to a integer
String s = Integer.toString(i) ??? Perhaps typed that a little too fast ;-) ?
Anyway, you can also use: int i = new Integer ( stringObject ).intValue (). However, it might be better to use Integer.parseInt ( stringObject ) as it is useless to instantiate an extra object.
U can use the following example...
String str = "10";
int strValue = Integer.parseInt(str).intV alue();
which would give the value 10 into the variable strValue.
Regards,
Pradeep
String str = "10";
int strValue = Integer.parseInt(str).intV
which would give the value 10 into the variable strValue.
Regards,
Pradeep
> String s = Integer.toString(i) ??? Perhaps typed that a little too fast ;-) ?
Not really.
Perhaps Felipe1976 typed the question too fast :)
Q. "How to Integer to a string"
Not really.
Perhaps Felipe1976 typed the question too fast :)
Q. "How to Integer to a string"
Is the question for Converting a string to an integer or the other way???
Regards,
Pradeep
Regards,
Pradeep
String str1 = "101";
int intVal = Integer.parseInt(str1);
int intVal = Integer.parseInt(str1);
>> int strValue = Integer.parseInt(str).intV alue();
No. Integer.parseInt () is enough. You cannot do an intValue () over a result from parseInt () because parseInt () returns a simple 'int and not an Integer object. Or else you can do: new Integer ( str ).intValue () -> but like I said, its a useless instantiation of an extra object.
No. Integer.parseInt () is enough. You cannot do an intValue () over a result from parseInt () because parseInt () returns a simple 'int and not an Integer object. Or else you can do: new Integer ( str ).intValue () -> but like I said, its a useless instantiation of an extra object.
Ok
Felipe1976,
We still don't know if you were trying to convert a String to an integer or an integer to a String?
We still don't know if you were trying to convert a String to an integer or an integer to a String?