14.3.8 String Method valueOf
As we’ve seen, every object in Java has a toString
method that enables a program to obtain the object’s string representation. Unfortunately, this technique cannot be used with primitive types because they do not have methods. Class String
provides static
methods that take an argument of any type and convert it to a String
object. Figure 14.9 demonstrates the String
class valueOf methods.
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.