Science, asked by LakshyaGupta279, 1 year ago

Can someone explain the java toString function with a example?

Answers

Answered by devooty10
0
In Java, the String class is encapsulated under java lang package. All the strings created in Java are of String type. Java string functions objects are immutable which means that the objects created once cannot be altered.
Following example shows the way to create an immutable object of String Class:

Public final class TestString { Final String str; TestString(String s) this.str=s; public String get() return str; }

In the above example, the TestString class is called the immutable class as the state of the class cannot be changed, once it will be created.

Similar questions