- Java data types fall into three main categories, namely, Boolean , character , and numeric . The numerical type is divided into integral type and floating point type. The basic data types of Java (8 types) are Boolean Boolean (1 bytes), character char (2 bytes), integer byte (1 bytes), short (2 bytes), int (4 bytes), Long (8 bytes), float float (4 bytes), Double (8 bytes). In addition, two kinds of variables, string and date, are often used in programming.
- The conversion of Java data types is generally divided into three types: conversion between simple data types, conversion of strings to other data types, conversion of other useful data types.
- conversion between simple data types &N Bsp , &NB Sp , &NB Sp , &NB Sp , &NB Sp in Java, Integer, real, and character types are considered simple data type from low to Advanced (Byte, short, char)---> int---> Long- -Folat---> Double . Conversions between simple data types can be divided into: low-to-advanced automatic type conversion, advanced to low-level coercion type conversion, wrapper class transition type conversion.
2. Conversion of strings to other data types
By looking at the member methods provided by each class in the class library, it can be seen that almost all classes derived from the Java.lang.Object class provide the ToString () method, which can be converted to a string. the wrapper class for the data type can use the ToString () method to convert the corresponding data into a string .
3. Convert character type directly to other data types as numbers
The conversion of a character variable to a numeric variable actually has two correspondence: one is to convert it to the corresponding ASCII value, and the other is a conversion relationship, such as converting ' 4 ' to 4 instead of ASCII value. For the second type of conversion, you can use the character getnumericvalue (char ch) method.
Java Fundamentals-Conversions between data types