- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 Articles
- Java Program to convert Double into String using toString() method of Double class
- Convert String to Long in Java
- Convert from String to long in Java
- Convert long primitive to Long object in Java
- The toString() method of Java AbstractCollection class
- How to convert Long array list to long array in Java?
- Override the toString() method in a Java Class
- How to convert String to Long in Kotlin?
- C# program to convert string to long
- Haskell Program to convert long type variables into int
- How to convert value to string using $toString in MongoDB?
- Convert Long to numeric primitive data types in Java
- Java toString() method.
- How to convert a double value into a Java String using format method?
- How to convert a double value into a Java String using append method?

Advertisements