|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
How to convert string into int in Java Can any one tell me the code in java to convert string to int. What are the syntax and declaration commands are used to convert string to int. Any help will be extremely appreciated. |
#2
| |||
| |||
re: How to convert string into int in Java You can convert a Java String to an int using the parseInt() method of the Integer class.The toString() method also convert Integer number to string number. The java.lang package provides this conversion functionality through toString() method. String can be converted into int in java by parseInt() method. Type casting is a method to change string to integer. |
#3
| |||
| |||
re: How to convert string into int in Java Code: import java.io.*; import java.lang.*; public class intst { public static void main(String[] avg) throws IOException{ BufferedReader read = new BufferedReader(new InputStreamReader(System.in)); System.out.pn("Enter the value"); String st = read.readLine(); String d = new Integer(str).toString(); System.out.pn("String:=" +d); } } |
#4
| |||
| |||
re: How to convert string into int in Java string to int in java : Code: public class strtoint { public static void main(String[] avg) { String stint="1234"; int M1=Integer.parseInt(str); // method 1 to convert string to int System.out.println("Type no string to integer :"+rM1); int M2=Integer.valueOf(str); System.out.prln("Type no string to integer :"+M2); |
![]() |
|
Tags: commands, convert string, java, string to int, syntax |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to convert string to char array in java? | Baazigar | Software Development | 6 | 10-01-2011 06:36 PM |
Convert string to binary in java | TechGate | Software Development | 5 | 28-01-2010 01:36 PM |
How to convert InputStream to String in java? | KALIDA | Software Development | 4 | 20-01-2010 06:16 PM |
How to convert String to Date object in java? | KALANI84 | Software Development | 4 | 20-01-2010 05:07 PM |
how to convert a boolean value to a string in java? | Janus | Software Development | 3 | 29-07-2009 08:07 PM |