Common data types in Java
Data type |
Data type Interpretation |
Description |
Char |
Character type |
Used to store a single character, such as: Gender "male", "female", Electric Light "on", "off" |
Int |
Plastic |
Used to store integers, such as the time of day is 24 hours, January is 31 days |
Double |
Double precision |
For storing small trees, such as Mengniu breakfast milk price is 1.3 yuan, mobile phone standby time is 6.5 hours |
String |
String |
Used to store a string of characters, such as "My hobby is playing football", "I Like Java program" |
Defining variables
Public classtest{ Public Static voidMain (string[] args) {CharA = ' P ';//A variable that declares and assigns a character shape (a single character) intNumber = 123;//variables that declare and assign values to reshape Doubleb = 1.5;//variables that declare and assign double-precision shapesString d = "Zifuchuan";//a variable that declares and assigns a string type//OutputSystem.out.println (a); SYSTEM.OUT.PRINTLN (number); System.out.println (b); System.out.println (d); }}
Types of Java variables, defining variables