Can someone explain the java toString function with a example?
Answers
Answered by
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.
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
Math,
7 months ago
Accountancy,
7 months ago
Computer Science,
7 months ago
Science,
1 year ago
English,
1 year ago
Math,
1 year ago