cancel
Showing results for 
Search instead for 
Did you mean: 

String to Integer

Former Member
0 Kudos

All,

How to assign the String value to Int variable?

BM

Accepted Solutions (1)

Accepted Solutions (1)

luciano_leitedasilva
Contributor
0 Kudos

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

Answers (3)

Answers (3)

Former Member
0 Kudos

Where does the string come from and why do you have to assign it to an int?

Armin

former_member187990
Participant
0 Kudos

Hi,

Try this Code

String no="1234";

int a;

a=Integer.parseInt(no);

Regards

Satish Kumar SV

Former Member
0 Kudos

HI Bharati,

You can Use Integer.parseInt("string value") for converting string representation of number to

interger.

hope this helps

With Regards

Naidu