

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert Long into String using toString() method of Long class in java
The toString() method gives string representation to a Long. Let’s say we have the following Long object −
Long longObj = new Long(70); System.out.println("Long: " + longObj);
To convert it to String, the toString() method is used −
String myStr = longObj.toString();
The following is the complete example −
Example
public class Demo { public static void main(String[] args) { // Long Long longObj = new Long(70); System.out.println("Long: " + longObj); // conversion String myStr = longObj.toString(); System.out.println("Converted to String: " + myStr); } }
Output
Long: 70 Converted to String: 70
- Related Questions & Answers
- Java Program to convert Double into String using toString() method of Double class
- Convert String to Long in Java
- Convert long primitive to Long object in Java
- Convert from String to long in Java
- How to convert Long array list to long array in Java?
- C# program to convert string to long
- How to convert String to Long in Kotlin?
- The toString() method of Java AbstractCollection class
- Convert Long to numeric primitive data types in Java
- What is long long in C/C++?
- Long style format for Date with Java MessageFormat class
- Convert Decimal to Int64 (long) in C#
- Pass long parameter to an overloaded method in Java
- Hexadecimal literal of type long in Java
- Override the toString() method in a Java Class
Advertisements