In this section, we will learn how to convert String to long. The following program provides you the functionality to convert String to long.
Code Description:
In this program we have taken a String as "String s = 20000" as shown below. To convert this String to long we have used "parseLong()" method in a try and catch block to catch the exception if occurs. Therefore we get the following output of the program as shown below.
Here is the code of the program:
public class StrToLong {
|
Output of the program:
| C:\unique>javac StrToLong.java C:\unique>java StrToLong long l = 20000 C:\unique> |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Convert String to long
Post your Comment