
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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 to 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
Advertisements