on 07-04-2007 1:45 AM
All,
How to assign the String value to Int variable?
BM
Hi there,
Have a look at the code below:
String x = "test";
int i = 0;
try{
i = Integer.parseInt(x);
}
cath(Exception e){
// do something
}
You have to be careful about invalid numeric string.
Regards,
Luciano
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Where does the string come from and why do you have to assign it to an int?
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try this Code
String no="1234";
int a;
a=Integer.parseInt(no);
Regards
Satish Kumar SV
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Bharati,
You can Use Integer.parseInt("string value") for converting string representation of number to
interger.
hope this helps
With Regards
Naidu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.