Numeric string conversion

8. numeric string conversion

8.1 java.lang class Number

  • The abstract class Number is BigDecimal, BigInteger, Byte, Double, Float, Integer, Long and Short superclass.

Abstract method

  • public byte byteValue (): returns the specified number as a byte. This may involve rounding or truncation.
  • public short shortValue (): Returns the specified value as a short. This may involve rounding or truncation.
  • public abstract int intValue (): returns the specified number as an int. This may involve rounding or truncation.
  • public abstract long longValue (): returns the specified number as a long. This may involve rounding or truncation.
  • public abstract float floatValue (): returns the specified number as a float. This may involve rounding.
  • public abstract double doubleValue (): returns the specified number as a double. This may involve rounding.
  basic string data type conversion Object into a String String to Object Type
Byte static byte parseByte(String s) String toString() static Byte valueOf(String s)
Double parseDouble toString()
Float parseFloat toString()
Integer parseInteger toString()
Long parselong toString()
Short parseShort toString()

8.2 java.lang class Integer

Field Summary

  • MAX_VALUE: a constant value of 2 ^ 31-1, which represents the maximum value that can be represented type int.
  • MIN_VALUE: a constant value of -2 ^ 31, which represents the minimum value of type int can represent.

Specific methods , , parseInt toString valueOf

  • public static int parseInt (String s, int radix): using the radix specified by the second argument, the string parameter analysis is a signed integer, parseInt ( "1100110", 2 ) returns 102.
  • public static int parseInt (String s) : the string argument as a signed decimal integer resolution.
  • public String toString (): Returns a String object of the Integer's value.
  • public static String toString (int i) : Returns a String object representing the specified integer.
  • public static String toString (int i, int radix): Returns the first argument to the base represented by the second argument string representation.
  • public static Integer valueOf (int i) :  Returns a specified instance int Integer value.
  • public static Integer valueOf (String s) : Returns Integer String object values stored specified.
  • public static Integer valueOf (String s, int radix): return an Integer object stored in the base by the second argument when parsed to extract from the specified String value.
  • public static String toBinaryString (int i) : Returns an integer parameter binary (base 2) unsigned integer string representation.
  • public static String toHexString (int i) : Returns an integer argument in hexadecimal (base 16) unsigned integer string representation.
  • public static String toOctalString (int i) : Returns a string argument integer octal (base 8) unsigned integer representation.

Guess you like

Origin www.cnblogs.com/Stephanie-boke/p/11515210.html