Configuration

Night mode

ToString

Java Basics Course

Engineers From These Top Companies and Universities Trust EXLskills

1M+ Professionals | 100+ Institutions

This is the EXLskills free and open-source Java Basics Course. It guides learners via explanation, demonstration, and thorough practice, from no more than a basic understanding of Java, to a moderate level of essential coding proficiency.

Is this course FREE?

Yes, this a 100% free course that you can contribute to on GitHub here!

Have more questions?

Conversions

ToString

Another string conversion method that will prove useful to you in the future is the toString() method, which takes almost any object in Java and converts it to a String. Let's take a look at this example.

This method is useful when you want to print certain expressions. Although primitive data types that we have covered up to this point would print without needing to be converted into a String, there will be other objects we will master, such as arrays, that cannot be print directly, so keep the toString method in mind as we move forward and learn about arrays.