- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
What is the purpose of toString() method? Or What does the toString() method do in java?
The toString() method returns the current object in String format.
Example
public class Test { public static void main(String args[]) { Test obj = new Test(); System.out.println(obj.toString()); System.out.println("Hello"); } }
Output
Test@2a139a55 Hello
- Related Articles
- What does the method toString(obj[] a) do in java?
- What does the method toString(int[] a) do?
- Java toString() method.
- The toString() method of CopyOnWriteArrayList in Java
- Java Signature toString() method
- The toString() method of Java AbstractCollection class
- LocalDateTime toString() method in Java
- LocalTime toString() method in Java
- MonthDay toString() Method in Java
- Instant toString() method in Java
- LocalDate toString() method in Java
- ShortBuffer toString() method in Java
- Provider toString() method in Java
- Duration toString() method in Java
- StringJoiner toString() method in Java 8

Advertisements