Computer Applications
Describe wrapper class methods available in Java to parse string values to their numeric equivalents.
Java Library Classes
4 Likes
Answer
The wrapper class methods available in Java to parse string values to their numeric equivalents are described below:
parseInt(string) — It is a part of wrapper class Integer. It parses the string argument as a signed integer. The characters in the string must be digits or digits separated with a decimal. The first character may be a minus sign (-) to indicate a negative value or a plus sign (+) to indicate a positive value.
Syntax:int parseInt(String s)parseLong(string) — It is a part of wrapper class Long. It parses the string argument as a signed long. The characters in the string must be digits or digits separated with a decimal. The first character may be a minus sign (-) to indicate a negative value or a plus sign (+) to indicate a positive value.
Syntax:long parseLong(String s)parseFloat(string) — It is a part of wrapper class Float. It returns a float value represented by the specified string.
Syntax:float parseFloat(String s)parseDouble(string) — It is a part of wrapper class Double. It returns a double value represented by the specified string.
Syntax:double parseDouble(String s)
Answered By
3 Likes