---
title: "What is the purpose of toString() method in java ?"  
description: "What is the purpose of toString() method in java ?"  
author: "Anonymous User"  
published: 2015-04-27  
updated: 2020-09-20  
canonical: https://www.mindstick.com/interview/2440/what-is-the-purpose-of-tostring-method-in-java  
category: "java"  
tags: ["java", "string"]  
reading_time: 1 minute  

---

# What is the purpose of toString() method in java ?

The toString() method returns the string representation of any object. If you print any object, java compiler internally invokes the toString() method on the object. So overriding the toString() method, returns the desired output, it can be the state of an object etc. depends on your implementation.

## Answers

### Answer by Anonymous User

The toString() method returns the string representation of any object. If you print any object, java compiler internally invokes the toString() method on the object. So overriding the toString() method, returns the desired output, it can be the state of an object etc. depends on your implementation.


---

Original Source: https://www.mindstick.com/interview/2440/what-is-the-purpose-of-tostring-method-in-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
