The String and StringBuffer Classes |
The String class itself does not provide any methods for converting a String to a floating point, integer, or other numerical type. However, four of the "type wrapper" classes (Integer, Double, Float and Long) provide a method namedvalueOf()
that converts a String to that type. Here's a small, contrived example of the Float class'svalueOf()
.String piStr = "3.14159"; Float pi = Float.valueOf(piStr);valueOf()
is a static method.
The String and StringBuffer Classes |