Java Program to Convert String to Long
Given a String, the task is to convert it into Long in Java.
Input : String = "20" Output: 20 Input : String = "999999999999" Output: 999999999999
We can use various methods to perform the task :
A. Using Long.parseLong()
B. Using Long.valueOf()
long varLong = Long.valueOf(str);
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.