onlinecode

Convert a string to long in Java

Convert a string to long in Java

In this post we will give you information about Convert a string to long in Java. Hear we will give you detail about Convert a string to long in JavaAnd how to use it also give you demo for it if it is necessary.

To convert a string to long, we can use the Long.valueOf() method in Java.

Here is an example:

String str = "1234854";long number = Long.valueOf(str);System.out.println(number);

Output:

1234854

Alternatively, you can also use new Long() constructor to convert a string to long.

String str = "1234854";long number = new Long(str);System.out.println(number);  // 1234854

Hope this code and post will helped you for implement Convert a string to long in Java. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Exit mobile version